I want to contribute a module I wrote recently: MailChimp Import. This module imports already-sent campaigns (aka newsletters) from a MailChimp account, as Drupal nodes. (MailChimp is a nice third-party newletter/email campaign management system.) The module is complet, functional, and usable. However, I do intend to add more configurability to it in the next few months.
EXISTING MODULES
There is already a main MailChimp module ( http://drupal.org/project/MailChimp ), which provides functionality for enrolling users in one's MailChimp mailing lists. It doesn't import campaigns. My module depends on the main MailChimp module, and is not intended to duplicate or replace any of its functionality.
My module depends on MailChimp module for two reasons: 1) so that it can use the API that is included with MailChimp module, and 2) so that it can use the same account settings as MailChimp module, so users don't have to enter their MailChimp account credentials twice.
As far as I can tell from searching d.o and g.d.o, and consulting with the maintainers of related modules (MailChimp and EMF), there is no other module that does what MailChimp Import does.
COMMUNITY
I've discussed this with the maintainer of MailChimp module, Drupal user LouBabe ( http://drupal.org/user/54135 ). I recommended, and LouBabe agreed, that my module should be added separately for now, rather than being a child module of the main MailChimp module, because it may soon belong more under the umbrella of EMF or Feeds, depending on which direction I take in adding features to it.
I've also discussed this module with alex_b ( http://drupal.org/user/53995 ), who recommended that I provide a Feeds plugin with this module, so that users can choose to import their MailChimp campaigns as feeds. I intend to do this as my next improvement on this module, because by doing that I can provide more flexibility (particularly CCK field mapping), piggybacking on the existing Feeds code rather than writing much more of my own.
FUNCTIONALITY
On installation, MailChimp Import creates a table which stores MailChimp campaign ID's against Drupal node IDs.
The settings page at admin/settings/MailChimp_import provides some options about the import.
All information that's pulled from MailChimp is pulled through their API, using the copy of the API that's included with the main MailChimp module, and the account credentials configured on the settings page for the main MailChimp module. (Until that config is done, MailChimp Import won't do anything, and its settings page will contain only a message advising the user to do that config and providing a link to the MailChimp settings page.)
MailChimp Import uses hook_nodeapi() to delete records from the MailChimp_import table when the corresponding nodes are deleted. This means that next time the import is run (either from the settings page or with cron), those campaigns will be imported again. This is provided in case the user imported some campaigns with the wrong content type or filter settings, and wants to re-import.
Here is a screenshot of the settings page for MailChimp Import: http://skitch.com/zoen/n27nf/mailchimp-import-settings-local.d6 Things to note:
- At present, the only options provided are:
- Which of your MailChimp mailing lists to import campaigns from
- The node type of imported campaigns
- The input format of imported campaigns
- Whether or not to check for new campaigns to import on every cron run
- There is a button to import campaigns immediately.
Here is a link to my blog post about this module, which was posted into Planet Drupal: http://affinitybridge.com/blog/module-import-MailChimp-newsletters-your-...
SECURITY
The only table MailChimp Import ever queries directly is its own table, MailChimp_import. Argument substitution is used with all arguments.
check_plain() is used in the one place where a string is inserted directly into the DB. The string is a campaign ID from MailChimp, not a direct user input, but hey, you never know.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | mailchimp_import.tar_.gz | 5.79 KB | zoen |
| #1 | mailchimp_import.tar_.gz | 3.42 KB | zoen |
Comments
Comment #1
zoen commentedAnd here's the module.
Comment #2
avpadernoHello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, pointing out what needs to be changed.
Comment #3
zzolo commentedHello. My initial glance at the code suggests that it follows Drupal coding standards pretty well and looks well coded. A couple general things.
Use t() correctly with replacement values, as well as use t().
This seems unnecessary. If this function should be generic, at least change the names of the parameters.
Overall, well done, keep up the good work.
Comment #4
arianek commentedhey zzolo -
i work with zoe, and we were discussing whether this would make a nice submodule of the main mailchimp module. is there anything special that needs to be done for this to be considered as such (other than obviously talking to the main module maintainers)?
otherwise, consider me generally vouching for zoe's awesomeness and deservingness of a cvs account. i know she'll do us proud. ;-)
a.
Comment #5
zzolo commentedHey Ariane, your kinds word are always appreciated, but we don't really do a voucher program for the CVS accounts. :)
My suggestion is to start a discussion with the module maintainer. To get a CVS account for co-maintaining a module, you need a thread in the issue queue of the given module that specifically states that the owner of the module wants the person applying to be a co-maintainer. The maintainer may want to use the code but not make you a co-maintainer, at which point, we still can't give you a CVS account without another application.
I think adding this module to the existing MailChimp module is the way to go. But I don't think it's necessary to get a CVS account and continue the review of this module for the application.
Let us know what direction you want to take, and feel free to ask more questions.
--
Alan
Comment #6
arianek commentedYah well, still can't hurt. ;-)
Having stuck mostly to core stuff so far, I didn't even know the process for such things, so that is very helpful information... Will see what Zoe sorts out as far as which direction to take with this!
Comment #7
zoen commentedHi Alan,
Thanks for the help with the code - I've implemented all your suggestions. At the moment I'm emailing with the maintainer of the main MailChimp module, to talk about collapsing this module into theirs, probably with me as co-maintainer. If they're into that, we'll start the appropriate thread in the MailChimp issue queue, and close this one.
---
ZOD
Comment #8
avpadernoIf you are accepted as co-maintainer, you still need a CVS account to commit code into Drupal.org repository.
Comment #9
avpadernoIs there any update on this?
Comment #10
avpadernoComment #11
arianek commentedno wonder i couldn't find this, it was closed! reopening - zoe's been away and is still working on this, so would be great if you can leave it open a bit longer. thanks kiam!
Comment #12
zoen commentedHiya. So the maintainers of the main MailChimp module (hereafter referred to as Team Chimpy) are somewhat hesitant to add this to the module, and are asking me which direction we should go with it.
These appear to be the options:
Team Chimpy have said they'd pretty much be willing to go whichever route is the consensus. I like option 1 best, 'cause then Team Chimpy don't have to babysit my code, and also, my module doesn't have to be more clutter in the contrib module list. So I guess now the next move is for me to get an official O.K. on this plan from Team Chimpy.
Comment #13
zzolo commentedTeam Chimpy! Awesome.
First off, if this is an issue somewhere else, can you link it up here so we can check out discussion.
As far as whats best, IMO, you should put this code in the MailChimp module and ZoeN should become a co-maintainer. This should be explicitly approved by the owner of the MailChimp module in that issue or this one.
Comment #14
zoen commentedGradually, gradually sorting things out with the MailChimp maintainer, who is having new-baby amazingness right now. Please bear with us.
Comment #15
avpaderno6 weeks are passed from the last comment; are there any news?
Comment #16
zoen commentedNope.
Comment #17
avpadernoLet's proceed with the review of the proposed module; if they didn't reply so far, it's useless to wait any longer.
Comment #18
zzolo commentedHi @ZoeN, can you upload a new version of the module with my comments address form #3 above.
Comment #19
zoen commentedHi @zzolo. Indeed I can.
This new version also provides a couple of new options:
Also it's re-jigged a bit to work properly with the latest version of the main MailChimp module (the authentication vars used to be MailChimp username and password; now it's just MailChimp API key)
Comment #20
avpadernoComment #21
zzolo commented@ZoeN, thanks for the application and patience. The following points do not necessarily encompass all of the changes that may be necessary for your approval. Also, a specific point may just be an example and may apply in other places.
It is unnecessary to run title and description through t() as this is done by default.
Consistency on using the dot operator correctly (space on both sides).
Consistency with array structures. Either one is fine (though I personally prefer the latter :)
What is $field for or from?
Your spacing is way off (in other places as well). Also, I would consider using hook_requirements to ensure that the module cannot be installed without an API key int eh MailChimp module. Oh, and this should just be a drupal message, not a form item.
Your use of system_settings_form seems a bit off. That function will save all form items as variables. This means there is no reason to reference your variables and array indexes in them. It also means that you are probably not deleting all the variables you are creating, specifically your new button.
You should be using $form_state['values']. Also, since this is the submit function, you will have the values form the form, so there is no need to look into the variables.
These could be combined into one if..else. Also, the usual coding Drupal paradigm is to check for the opposite and return, thus creating a structure that is not full of nested if..else statements.
Overall, this is looking good. These are mostly minor things; just needs some cleaning up.
--
Note: Please be patient with the CVS application process. It is all done by volunteers. Our goal is not to be arbitrarily slow or meticulous. Our goal is to get you CVS access and ensure that you are and will become a more responsible Drupal contributor. For a quick reference on what I look for in a code review, please see this article.
Comment #22
zzolo commentedComment #23
avpadernoPlease read the following links as this is very important information about CVS applications.
Drupal.org has moved from CVS to Git! This is a very significant change for the Drupal community and for these applications. Please read Migrating from CVS Applications to (Git) Full Project Applications and Applying for permission to opt into security advisory coverage on how this affects and benefits you and the application process. In short, every user has now the permissions necessary to create new projects, but they need to apply for opt into security advisory coverage. Without applying, the projects will have a warning on projects that says:
Comment #24
avpaderno