Firefox PHP

Module: Forum Subscriptions

Posted by Joe Curia 
Module: Forum Subscriptions
February 26, 2010 11:04AM
This module allows users to subscribe to all forums or individual forums in order to receive emails when new messages are posted. It provides users with the option to receive emails for all new messages or only new threads. It also allows users to choose to receive an email for each new message when it is posted, or (if the admin allows it) in a daily or weekly digest email which contains all of the messages from the previous day or week.

If you are not able to create a cronjob to process mail queues, this module can still send emails after each message is posted. If you are able to create a cronjob, this module will queue the emails to be sent after each message is posted so that the posting process is not delayed. This module will also then be able to send daily and weekly digests.

Template Customization:
If you would like to make subscription links available on the index and list pages of your forum you can make the following template edits. These subscription links will subscribe a user either to "All Forums" from the index page or to an individual forum from its list page.

For the index page, edit {your_template}/index.tpl. For the list page, edit {your_template}/list.tpl and {your_template}/list_threads.tpl. Wherever you want the link to appear, add these lines:
{IF URL->FORUM_SUBSCRIPTION}
<a href="{URL->FORUM_SUBSCRIPTION}">{FORUM_SUBSCRIPTION->SubscribeURLText}</a>
{/IF}

Message Customization:
Before uploading this module, you may want to customize the email messages sent by the module. Those messages are found in the forum_subscriptions/lang/your_lang.php file. Please note that the fields wrapped in %'s (e.g. %subject%) are variables drawn from the forum messages and are inserted when the emails are sent.

Subject for emails sent after each post: NewMessageSubject
Body for emails sent after each post: NewMessage

Subject for daily digest emails: DailyDigestSubject
Body for daily digest emails: DailyDigestBody

Subject for weekly digest emails: WeeklyDigestSubject
Body for weekly digest emails: WeeklDigestBody

Individual messages in an "All Forums" digest: AllForumsDigestFormat
Individual messages in a single forum digest: SingleForumDigestFormat
Separator which appears between messages in a digest: DigestSeparator
* Please note that in the individual message formats there are a number of special fields (eg. %SubjectIntro%). These fields are "digest_variables" which can be found at the end of the language file.

Example Email:
From: System Email //set in the general settings
To: User Email
Subject: New message in the Sample forum at Sample Site.
Body: //full body shown between ~~~ lines which do not appear in actual email
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Author: Sample Author
Subject: First Post

Message:
Hi,  This is my first post to this sample forum.  I hope to become an active
member here.

View the full thread: [www.samplephorum.com]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using a Cronjob Mail Queue:
If you would like to use the Cronjob Mail Queue option you will need to complete two steps:

First, you must add a cronjob to call the Phorum "scheduled" hook from the Phorum script.php file. I would recommend that this cronjob run every minute. The module will handle any time-outs or errors which otherwise could cause the cronjob to run two instances of this module. This is one example cronjob:
* * * * * cd your/phorum/root && /usr/bin/php ./script.php --scheduled
There should be no output from this script unless there is an error. If possible I would also advise that you have the output from this script either logged or emailed.

Second, you must enable the Mail Queue option from this module's settings page.

Your Forum Subscriptions emails should now be sent through the mail queue system. I would advise enabling the "Debug email" setting for this module until you are sure the mail queue system is working properly.

Notes:
I would advise turning off email notification if you use this module as email notification could result in a double email. One from the forum subscription and one if the user elected to follow the thread. If not you will probably want to educate your users as to the different options available.

Todo:
- Add support for an unsubscribe link in each email which would automatically unsubscribe the user from future emails sent by this module.

- Add support for HTML email.

- Add features as they are requested.

Changelog:
5.2.1.02
    - Enhancement: Dutch translation provided by Phorum user Franc with thanks 
      for the contribution.
    - Bugfix: Digest messages would not show the proper forum_id in the read 
      url.  Thanks go to Phorum users Marco and Lammi for reporting this bug.
    - Bugfix: Removed a PHP notice which could be generated in the Control 
      Center.  Thanks go to Phorum user korsakov for reporting this.
    - Bugfix: The "Subscribe to All Forums" link would erroneously appear in 
      folders within a vroot.
    - Bugfix: Fixed a bug which would occur if a moderated message was approved.
5.2.1.01
    - Bugfix: Fixed a bug ironically caused by the debugging system which could 
      cause a queue to exceed the PHP memory limit while attempting to insert 
      events into the event logging system.
    - Bugfix: Fixed a bug which could have caused messages in a digest to not 
      be sorted by posting date/time.
    - Bugfix: Fixed a bug which could cause a user to receive multiple emails 
      if they first subscribed to an individual forum, then subscribed to all 
      of the forums.
    - Enhancement: If the cronjob mail queue is finished well before the time 
      limit, the script will continue to the next queue rather than simply 
      stopping and waiting for the next cronjob.
    - Enhancement: Added the option to only show forums to which a user is 
      currently subscribed in the Control Center.  Thanks go to Phorum user 
      korsakov for suggesting this feature.
    - Enhancement: Added the ability to show subscriptions to forums in all 
      vroots in the Control Center.
    - Enhancement: Added support for vroots.  Thanks go to Phorum developer 
      Thomas Seifert for pointing out this need.
    - Enhancement: Added support for potential future database changes.
5.2.1.00
    - Started


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald




Edited 1 time(s). Last edit at 11/13/2010 11:11AM by Joe Curia.


Attachments:
open | download - forum_subscriptions_v5_2_1_02.zip (38.4 KB)
Re: Module: Forum Subscriptions
February 26, 2010 12:10PM
Thank you! Great job, Joe!! I just noticed that you list all available forums within the CC. Would it be possible to let Admins opt-in whether they want to display all available forums vs. the forums selected by the user? It becomes very unhandy with a long list of forums. Thank you!
Re: Module: Forum Subscriptions
February 26, 2010 12:23PM
Would a setting like this work for you: "From the Control Center users can subscribe to: (Dropdown: All Forums and Individual Forums, All Forums Only, Individual Forums Only)" If so, I will work on adding that setting, but it won't be till later this weekend.

EDIT: Ah, I think I misread a bit. You want to show individual forums, but only the ones the user subscribed to via the added subscription link on the list page.

I think I can work that in too.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald




Edited 1 time(s). Last edit at 02/26/2010 12:29PM by Joe Curia.
Re: Module: Forum Subscriptions
February 26, 2010 12:36PM
This would help. Ideally, I would like to give users only a subscription option when they are on a specific list page. Under the CC they would only see the subscribed forums. I would like to keep it as simple as possible and I am also afraid that it is too easy to subscribe to many forums on one page. What do you think?
Re: Module: Forum Subscriptions
February 27, 2010 06:42AM
just another option, I don't know if its implemented because I didn't get around to test it yet, would be, if I could opt to only show the forums from the current vroot to subscribe to but all forums I'm subscribed to to unsubscribe.

Overall - great module, thanks for implementing this!


Thomas Seifert



Edited 1 time(s). Last edit at 02/27/2010 06:43AM by Thomas Seifert.
Re: Module: Forum Subscriptions
February 27, 2010 09:44AM
Thomas, unfortunately vroots are one of my weak spots. I don't use them so I often forget them. This module does not take vroots into account at all right now. As long as a user has read access, they will see a forum, regardless of vroot. So, I will have to work on that. One question though: how would you want those subscriptions to appear? A list of all forums in the current vroot, then separate lists per vroot of only the forums to which a user has subscribed?

And that raises a further question. When a user subscribes to "All Forums" should I take into account the vroot they are in? So that if they are not in a vroot they would get messages from all forums not in a vroot, but if they are in a vroot they will get messages from all forums within their current vroot?

Thanks in advance for helping me better this module.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: Forum Subscriptions
February 28, 2010 07:45PM
Okay, I've installed this and am testing it out.

So far I think it is working just like the Group Auto Email module, but the advantage of this is that the users can control everything on there own.

I am not having success using the mail queue for some reason. As soon as I enable that, nothing gets emailed anymore. This must have something to do with my crontab command. It returned these in 2 emails right after I set it up.

/bin/sh: line 1: 16031 Killed /usr/bin/php ./script.php --scheduled > /dev/null
/bin/sh: line 1: 22811 Killed /usr/bin/php ./script.php --scheduled > /dev/null

Those 2 emails are the only ones I got from the "Cron Daemon".

My crontab, which should be correct, is...
**** cd /home/rlangle/public_html/members/yhwh && /usr/bin/php ./script.php --scheduled > /dev/null

I have debugging enabled, and am trying to figure out where to find the information I need.


Robert Angle
Phorum lover, nothing more.
Ruminations
Re: Module: Forum Subscriptions
February 28, 2010 08:00PM
Okay, I see that I need to have the event logging module enabled, which I have now done. Boy does it fill up fast with information too.


Robert Angle
Phorum lover, nothing more.
Ruminations
Re: Module: Forum Subscriptions
February 28, 2010 08:16PM
Okay, I decided to have Cron send to me instead of > /dev/null and saw that the script had a hang up with my pop3phorummail module. So I disabled pop3phorummail, but that's okay cause I need to change over to External Phorummail anyway.

Now everything is catching up, and all the test messages that I had posted over the last hour that did not get emailed to me, or now being emailed to me, one at a time, one per minute :-)

Is this the expected behavior? (everything is queued? and one post is processed per minute?)

- Bob


Robert Angle
Phorum lover, nothing more.
Ruminations
Re: Module: Forum Subscriptions
February 28, 2010 08:29PM
Quote
Robert Angle
Is this the expected behavior? (everything is queued? and one post is processed per minute?)

Okay, seems to be. That's cool. I had a lot of users posting when I was testing this out so it was a little overwhelming.

It isn't parsing my signature correctly though. It shows the link to the wordpress icon with the word "Ruminations" trailing the file name, as if it were part of the filename, making for a bad link. So I am going to disable signatures in the Forum Subscriptions module.

Now on to customizing messages...


Robert Angle
Phorum lover, nothing more.
Ruminations
Sorry, only registered users may post in this forum.

Click here to login