The current version of the module is not working with CiviCRM 3.3.x as API v1 was removed. The module uses api/Mailer.php
I added a patch to use api/v2/Mailer.php instead.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | compatibility_civicrm3.3.x.patch | 1.94 KB | thomas.feichter |
| compatibility_civicrm3.3.x.patch | 824 bytes | thomas.feichter |
Comments
Comment #1
EvanDonovan commented@thomasf:
Ah, I haven't used 3.3 yet, thanks.
Before I commit this patch, I'd like to know about its impact on CiviCRM version compatibility. What versions of CiviCRM, if any, would no longer work with the 6.x branch of CiviCRM Subscribe if this were committed? If there are versions >=2.1 that would no longer work, I would like to have some kind of compatibility layer, since I want CiviCRM Subscribe to work "out of the box" for all 6.x versions of CiviCRM.
Also, set to "needs review" when an issue includes a patch. Thanks for your contribution!
Comment #2
thomas.feichter commentedI was thinking it will be no problem to use api v2 since it was introduced in CiviCRM v2.0, but I just realized that api/v2/Mailer.php was missing until CiviCRM v3.2.4 (see: http://issues.civicrm.org/jira/browse/CRM-6821)
I attached a patch checking if CiviCRM Version 3.3 or higher is installed. If not, api v1 will be used.
Probably it could be implemented a bit nicer :) I didn't do the check on the file because file_exists() is not checking the include path and doing it manually would have been a bit more code.
I wasn't able to test it with versions prior to 3.3 because at the moment I have no installs. Maybe someone could check this...
Comment #3
EvanDonovan commentedThanks for the revised patch. I'll try to test this one before the New Year - got some other (paying) work to wrap up first. I'll have to set up a testbed with at least 2 version of Civi to test it though.
Comment #4
EvanDonovan commentedSorry for not looking at this sooner. Code looks like it should be reasonable. I will test it with my 2.x install soon, and this may be the last commit to this module (since I am planning on deprecating it in favor of CiviCRM Webform Integration).
Comment #5
colemanw commentedIt's kind of absurd to nest implode and explode together just to get rid of a dot.
Besides there's no reason to do so, the dot wasn't doing any harm anyway. All you need is this:
Not that those one-liner if statements are very drupalish. And comments go above the line, not on the same line, as the code they are referring to.
But aside from nitpicky stuff, this code does not seem to pass contact_id into the api, and I believe it is a required parameter.
How is either v1 or v2 api supposed to know what contact you are talking about?
Comment #6
EvanDonovan commented@colemanw: In re: the 2.2 branch, see http://svn.civicrm.org/civicrm/branches/v2.2/api/Mailer.php.
This is how the function is defined:
Thus, the wrapper function only needs an email address, not a Contact ID.
I won't quote the whole civicrm_mailer_event_subscribe() function from http://svn.civicrm.org/civicrm/branches/v3.3/api/v2/Mailer.php, but suffice it to say that it has the same kind of parameters.
That said, colemanw, I like your suggestion on simplifying the syntax. I think it would be even better for me to revive the old civicrm_subscribe() function and use that as a wrapper around this logic. That way the internal details of implementation would be hidden from the caller - i.e., the form submit function, and the civicrm_subscribe() function could be called from elsewhere if needed.
Comment #7
colemanw commentedI'm not sure if it is required or not, but at least the v2 API does accept contact_id as a @param. For this reason, I'm not a big fan of the v1 api (what if multiple contacts have the same email address? Too messy). So for my version of legacy support for webform_civicrm I've decided to just copy and paste the entire v2 civicrm_mailer_event_subscribe() function into one of my module's include files. Hey, it works. And I can get rid of it (and indeed all support for apis < v3) in the D7 version.
Comment #8
EvanDonovan commentedCommitted this to -dev as follows: http://drupalcode.org/project/civicrm_subscribe.git/blobdiff/bd9a4f9d4c7...
Comment #9
EvanDonovan commentedI've done some basic testing, but more would be wanted before I tag for the next beta.
Comment #11
shaneonabike commentedI can confirm that this in fact has resolved issues that I had with version of CiviCRM. Can I suggest that you actually deploy a new Beta version. I **generally** don't install dev versions on client sites just cause they are deemed unstable. But what you got here seems stable and you haven't released in a while?
Thanks for your awesome work!
Comment #12
EvanDonovan commentedSorry for not making another release. I am no longer maintaining this module since I stopped using CiviCRM last year, but am seeking a new maintainer.