This patch doesn't intend to add any new features to simplenews, just clean up a bunch of major issues in the code. DriesK, I hope I don't offend you with any of the below. This module is awesome and hopefully this will make it even awsomer (if that is a word). :) This is a huge patch and this isn't something that should be broken up since there are so many issues. I'm fine with branching this as 4.7.x-2.x-dev or whatever. OR, just heading towards D5 with this.
I noticed a bunch of code issues:
- FAPI wasn't being properly used
- there was no clean API
- lots of code style errors
- potential namespace conflicts ("sn_")
- convoluted variable names/logic
- and more
I'm pretty closing to finishing the above issues and I've also...
- Taken out activemaillib.php as it's pretty nasty in there and now we outsource sending HTML mails to mimemail.module if it's installed so we still need to let the user know that and improve the UI when it isn't installed (e.g. put some info next to mail type on node edit form)
Now we can form_alter the hell out of simplenews which will allow for excellent extensibility as a newsletter is a term/node combo so we've got those hooks already. The only other thing we should maybe add is a hook to the new API functions to let other modules act when a user has been subscribed/unsubscribed. I'll get to that next.
I'm also working on a complete rewrite of the simplenews_roles module which will allow syncing a mailing list with users in particular roles.
After this is done, extending simplenews to do more complex tasks will be much, much easier as we'll actually be able to use hook_form_alter() and some other goodies. And, the port to D5 will be way easier as well! I will gladly take the port on or help since I've got a pretty good handle on the code now.
Phew! Any suggestions are warmly welcome as I still have a bit of cleanup left.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | simplenews_9.patch | 134.48 KB | RobRoy |
| #3 | simplenews_7.patch | 133.62 KB | RobRoy |
| simplenews.cleanup.patch | 131.98 KB | RobRoy |
Comments
Comment #1
RobRoy commentedStill some work needed. Logic bug in confirm mail send, and some other stuff. I'll be finishing this up on Monday.
Comment #2
bluecobalt commentedThis is awesome RobRoy. Thanks for your work!
Comment #3
RobRoy commentedOkay guys, here is a massive patch. There is most likely still some bugs I've created with this rewrite, and some minor existing ones I didn't fix, so I'd really appreciate some thorough testing of this if anyone has a bit of time.
Now HTML mails are only an option when mimemail.module is installed.
Comment #4
csc4 commentedThanks for all your hard work on this - most impressive patch will give it a test now.
Not sure if this is a feature request or a bug but I'm still struggling with how to allow users individual newsletters which don't interfere with each other. There's a 'edit own newsletter' privilege which seems to suggest they should be restricted to their own but when creating they're shown all the names so allowing them to create issues on each others newsletters which doesn't seem right?
Comment #5
RobRoy commentedNot sure about that part csc4...
I did notice the hook_user() code needs updating. I missed that. Ugh...
Comment #6
markhope commentedThanks for all your work on this.
I can't comment on the quality of the code, but I have had a chance to do some initial testing.
1 error I am getting at the moment, from the 'Manage subscriptions' link under 'My Account':
Fatal error: Call to undefined function simplenews_subscription_manager() in /pathtodrupal/modules/contrib/simplenews/simplenews.module on line 512
I like the way that it now works with mimemail.module and that you've introduced theming for the various elements.
I've not had chance to test the theming yet.
One thing that is a big hang up for me is the relative links for images in outgoing mail. With theming a base url can be added, but it would be nice if the absolute url could be added automatically so it 'works out of the box'. I can't think of an instance when this wouldn't be needed other than if the images were embedded.
Mark
Comment #7
RobRoy commentedThanks Mark. This patch fixes that undefined function error, which I spotted in hook_user after putting up that other patch. And this fixes a lot of other bugs I found. I guess I was a bit too hasty. :)
This patch should be a lot closer.
Mimemail should handle absolute URLs for images, but I haven't tested just simplenews. With the current patch, you can only send plain text emails with simplenews, and you need mimemail for HTML messages so is this still an issue? I didn't like the duplication of code, so went for exporting the HTML email handling to Mimemail, and think with dependencies in D5 it will be much cleaner to require mimemail.module if we need to.
Thoughts?
Comment #8
markhope commentedI'll give the new patch a test out.
That's good that mimemail handles the absolute urls for images, and I like that multi-part sending option. I'll give this another tryout, and include some theming tests.
BTW is it usual for mimemail to encode the entire html portion as base64? I thought this was only used for attached images? It's quite hard to see what's going on in the received email code.
Mark
Comment #9
onionweb commentedyou can add support for absolute urls by changing in simplenews.module
to
Comment #10
RobRoy commentedI'm not sure. Can DriesK or someone else with more mail encoding expertise answer this one? The mails display fine, but viewing the source isn't an option. Not a huge deal, but would be good to know.
Comment #11
sillygwailoI did a little bit of testing, but note that I didn't test pre-patch, that is, I updated to the latest 4.7 VPS and applied the patch.
Nothing obviously broken in sending out newsletters, first a bunch of plain text newsletters, then a couple of HTML newsletters using Mimemail, with the only HTML being an <img> tag pointing to an external image.
Comment #12
umonkey commentedNow that Drupal 5 is right around the corner, do you think it's a bad idea to abandon the 4.7 version?
Comment #13
bluecobalt commentedYes, it's a bad idea to abandon 4.7. There are many of us who will be using 4.7 for months to come, and these are fixes that have been needed for a while.
Drupal 5 may be "just around the corner", but the contributed modules are months away from being updated and debugged so that everything works smoothly in 5.
Of course, by then some people will be wanting to abandon 5 before all of the pieces are in place so they can jump to the latest new thing. Such a vicious cycle which can make real-world implementation quite difficult.
peace,
blue
Comment #14
Tobias Maier commented+1 for your great patch!
I was not able to test it on my system, because I don't sit on my testing machine.
but I reviewed it visually...
the only thing I found is this:
it is better if you do this:
the same for
and
Comment #15
markhope commentedI've tested the patch and eveything is working smoothly for me.
I've still not got the absolute urls working for images.
unionweb suggested some code to replace, but that doesn't appear in the patched module code.
Can this be included as it doesn't look like mimemail does this.
For now I'm hoping to add the preg_replace pattern to template.php and overide the theme:
Can somebody tell me how to apply this?
Rob, I also think the code should include a header theme - maybe the site logo by default.
Great work!
Mark
Comment #16
markhope commentedRob,
I've had a quick look at mimemail project page and it says:
# If the HTML has embedded graphics, these graphics are MIME-encoded and included as a message attachment.
# Adopts your site's style by automatically including your theme's stylesheet files in a themeable HTML message format
I'm not sure that including images as attachments is the best way to go - are you?
Also there doesn't seem to be much in the way of my sites styles coming through with the mail. This isn't a problem for me as I'd rather send a restricted set of styles anyway. I'd hoped to include this in the theming functions.
I'm sure these pointers come under 'feature requests', which I know you're not looking at with this patch.
Mark
Comment #17
markhope commentedI've now applied this patch on a live/test server and the images are being included with the mail. The images are sent as attachments as intended with mimemail.module. I'd prefer the images to be referenced off the server, but I guess that's an issue for mimemail.
I've used template.php to overide the css inclusion and send only the code I need:
It's now quite usable for me.
Thanks
Mark
Comment #18
markhope commentedI'm using the patched version on a live site now, and through some recent testing have noticed that the 'Display block message' only works if the user doesn't have 'subscribe to newsletters' access control.
So a message like 'Stay informed on our latest news!' is only displayed for users that can't subscribe. :(
I'm assuming this isn't by design?
Comment #19
RobRoy commentedI think I'm going to commit these changes to a 4.7.x-2.x-dev branch so we can have a place to test this code with 4.7 too. I'll get to that as soon as I can and then we can file separate issues against that version. Thanks for the testing Mark, keep it up! :)
Comment #20
markhope commentedkeeping it up!
Under the settings for a newsletter there is an option for HTML to text conversion. The options don't work as the plain text version (within multi-part html and plain text) always sends with numbered links at the footer.
Comment #21
buddaLooking forward to giving this a spin in the 4.7.x-2.x-dev branch :)
Comment #22
RobRoy commentedI have branched these changes to 2.x-dev for 4.7 so please test that out. (I still have a few changes from HEAD I'm going to backport.)
@markhope: Can you file new, separate issues against that version for any bugs you find? Thanks!
Comment #23
markhope commentedYes I'll post issues against the new version - will I need to get this from CVS? I've not done much testing and issue posting before.
Budda, good to see you here! I'm using your returnpath module but it doesn't seem to be working with mimemail, now used with this version of simplenews. (but that's a separate issue I guess).
Comment #24
(not verified) commented