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) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • activity/email/add - how to amend this form
Pages: [1]

Author Topic: activity/email/add - how to amend this form  (Read 873 times)

michaellenahan

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
    • mick.appspot.com
activity/email/add - how to amend this form
February 10, 2012, 12:49:54 pm
Hello everyone

We are using ACLs to give access to Green Party membership secretaries so that they can see the members of their own local party.

It's working nicely. We have done it via reports which let them see the current members, expired members and so on.

We are also thinking about how to give local party secretaries the ability to email their members.

We want a nice clean workflow for this, so instead of using the bulk mailer (civicrm/mailing/send) we're thinking about using the "easy mailer" (activity/email/add) --- sorry, not sure what the proper terms are for these two types of mailing mechanism.

One disadvantage of the "easy mailer" approach is that this mechanism does not work well for large numbers of emails. So we'd appreciate thoughts on ways around this, because we like the idea of giving these non-technical users an easy way to send emails to their constituents. It's quite intuitive.

So when a logged in membership secretary goes to activity/email/add they can create an email and add the recipients. The ACL where clause hook is respected, so the recipients are from the list of those in the local party. Sweet!

My question is this. I would like to give them a drop-down with a choice of pre-set groups: "members of the local party" and "supporters (non-members) of the local party".

To complicate things, these pre-set groups are not actually CiviCRM groups. There are so many of them we don't want to set them up as groups. The local party is stored in a custom field and we can create the "recipient group" on the fly with SQL.

So, the question. Anyone out there with tips on how to do this. I guess something like hook_civicrm_buildForm() to build the form. And we're wondering maybe about using hook_civicrm_postProcess to route the email via CiviMail.

Thanks for listening and very grateful for your thoughts.

Michael L

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: activity/email/add - how to amend this form
February 10, 2012, 03:45:27 pm

How many members are there? If this is more than 100, i would definitely advise against using the "send email in a loop" workflow

You know, u can send a bulk email from search right? i.e. search for a set of contacts and then send all those contacts a bulk email which drops u into the civimail workflow

You can also create just two groups:

"members of the local party" and "supporters (non-members) of the local party"

and what a person can see should change based on their permissioning. Which reminds me this might be completely broken due to caching of smart groups, i.e. i dont think acls and caching work very nicely together

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: activity/email/add - how to amend this form
February 10, 2012, 10:42:00 pm
isn't the answer fixing civimail and getting rid of the wizard?

. Like civievent or phplist
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

michaellenahan

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
    • mick.appspot.com
Re: activity/email/add - how to amend this form
February 18, 2012, 04:14:28 am
In the end we opted for the simple email workflow, accepting its drawbacks.

The civimail workflown is not easy to hook into, I agree with you xavier. It would have needed quite a bit of work to make it intuitive for our target users.

We found a way to 'inject' the required emails into the 'To' box, based on a value that we pass on the query string.

We're using hook_civicrm_buildForm() and checking for CRM_Contact_Form_Task_Email.

So now if we go to:

civicrm/activity/email/add?atype=3&action=add&reset=1&context=standalone&recipients=all-members

... my code picks up the recipients=all-members from the query string and builds the list of members belonging to the logged-in user using SQL.

The code is here:

https://github.com/michaelmcandrew/gp/blob/master/modules/custom/gpew_local_party_access/gpew_local_party_access.module

See the bit which contains this comment:

    /*
* Here is some pasted code from
* CRM/Contact/Form/Task/EmailCommon.php
* line 185 onwards on version 3.3.5
*
* It takes $form->_contactIds and creates the toContact variable
* which is used by the template.
*
* What does this do?
* It lets us inject new items into the email To field.
* We populate an array form->_contactIds
* these contactIds are sent to the template in a way that the template
* can populate the facebook-style 'To' field on
* civicrm/activity/email/add
*
* The line that does this is:
* $form->assign('toContact', json_encode( $toArray ) );
* ... this assigns a value to a variable in the .tpl file.
*
* See: civicrm/templates/CRM/Contact/Form/Task/Email.tpl
* Search for: toContact
*/

Grateful for comments about this approach from other developers.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • activity/email/add - how to amend this form

This forum was archived on 2017-11-26.