UBB.Dev
Mod Name / Version: Digest or Instant Subscriptions 1.0

Description: This allows users to not only "subscribe" to forums via email, but they can choose the standard Digest Version from Threads, generated via cron of the subscriptions script, OR they can choose to receive the emails of new posts instantly.


Working Under: UBB.Threads 6.2

Mod Status: Beta

Any pre-requisites: You must run a subscriptions cron job as normally required for UBB.Threads to offer subscriptions. Help with cron jobs can be found http://www.ubbcentral.com/resources/cron.html


Author(s): JoshPet

Date: 04/30/03

Credits: CloudyNights.com for commissioning it. Also this is based on the Subscriber Emailer hack by Lunatic

Files Altered: editemail.php, changeemail.php, editemail.tmpl, addpost.php, and either /cron/php/subscriptions.php OR /cron/perl/subscriptions.pl

New Files: none

Database Altered: U_EmailDigest field added to the users table.

Info/Instructions: Follow the instructions posted here, then instruct users to adjust the "digest" setting in he Email Preferences page of "My Home".

Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.

Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.




Attached File
Thx Josh! This is very handy for smaller boards.
Josh it seems I can not alter the data base from the web interface that my host gives me. I hate to ask but I will, could you make an altertable.php to make this so I can use it and it will be simple for others. This is just what I want for our union site... This may be asking too much but I figure it is worth a try...

Thanks either way... Great hack
OK - download the attached text file - give it the extenions of .php instead of .txt and upload to your threads directory.

Run it in your browser - and you should be set. Then delete it from the server when you are done.

Josh

Attached File
79428-digestalter.txt  (24 downloads)
Josh,

I tried your hack on UUBT 6.3.1 and I'm getting the following SQL error. Can you help?

URL is http://glade-crossing.com/ubbthreads/ubbthreads.php

SQL ERROR: Unable to do_query: UPDATE gcna_Users SET U_EReplies = 'On', U_Notify = 'On', U_AdminEmails = 'On', U_EmailFormat = 'plaintext' U_EmailDigest = 'no' WHERE U_Username = 'Mike_Tabat'
You have an error in your SQL syntax near 'U_EmailDigest = 'no' WHERE U_Username = 'Mike_Tabat' ' at line 7

[]JoshPet said:
Mod Name / Version: Digest or Instant Subscriptions 1.0

Description: This allows users to not only "subscribe" to forums via email, but they can choose the standard Digest Version from Threads, generated via cron of the subscriptions script, OR they can choose to receive the emails of new posts instantly.


Working Under: UBB.Threads 6.2

Mod Status: Beta

Any pre-requisites: You must run a subscriptions cron job as normally required for UBB.Threads to offer subscriptions. Help with cron jobs can be found http://www.ubbcentral.com/resources/cron.html


Author(s): JoshPet

Date: 04/30/03

Credits: CloudyNights.com for commissioning it. Also this is based on the Subscriber Emailer hack by Lunatic

Files Altered: editemail.php, changeemail.php, editemail.tmpl, addpost.php, and either /cron/php/subscriptions.php OR /cron/perl/subscriptions.pl

New Files: none

Database Altered: U_EmailDigest field added to the users table.

Info/Instructions: Follow the instructions posted here, then instruct users to adjust the "digest" setting in he Email Preferences page of "My Home".

Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.

Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.


[/] [:"black"] [/]
Look for this part in changeemail.php
Code
<br />		U_EmailFormat    = '$EmailFormat_q',<br />		U_EmailDigest    = '$EmailDigest_q'<br />		WHERE U_Username = '$Username_q'<br />


I suspect you ar missing the coma at the end of the email format line.
That was the problem. Hard to see. Good eye!!

Thanks for the hack and the assist!

Mike
[]JoshPet said:
Mod Name / Version: Digest or Instant Subscriptions 1.0

Description: This allows users to not only "subscribe" to forums via email, but they can choose the standard Digest Version from Threads, generated via cron of the subscriptions script, OR they can choose to receive the emails of new posts instantly.
[/]

Josh...this interests me greatly, and I had asked about this somewhere (probably on the infopop support board) and been told you couldn't get individual "instant" emails on a FORUM (as opposed to a thread). As I read your description, for those who subscribe to a forum, this ADDS the alternative of receiving instant emails of posts INSTEAD of the daily digest. Am I interpreting this correctly?

Thanks! Tony
Yes, it allows them to subscribe to the forum.... either for a daily digest or instant notification. It doesn't work with the "Favorite Forums" bit, but rather the subscriptions.
great! Thanks - Tony
Josh...I think I want to try this on my test board this weekend.

So this requires adding that field to the database. I would have to do that, I guess, via the phpadmin tool that the website provides, and THERE the potentially relevant things appear to be:

1) the box for running queries, or

2) the place for creating a new table, where there are entry boxes for the table and the field(s) (all the latter in one box, I guess)

Is 2) where I would do something? e.g., naming an existing table and puttin gin the new field?

However, your code appears to be more in the form that I think I've seen recommended to people for running queries.

IS there a simple guide to where one does "easy" things like this, where the code is already provided to us?

Thanks - Tony

PS and I understand the bit about backing up the database first, except that I have no way of knowing whether the backups are usable...so many diverse things mentioned. I have been using the following:

- I select the tables to be backed up (in this case, I guess I select ALL, since we are altering the database)
- I check structure and data
-I check complete inserts
- I check send
and I hit "Go"

I would select one of the zipped options, except I've gotten 2 stories on which, AND I've found the only actually free zip program I could find didn't handle g or b zipped...guess I ought to spring for winzip, huh?

To take this a bit further, how can I check whether the backups are really valid? I do have a test board, so I guess I could use the backup from my main board, and maybe change all the tablename prefixes, and then go through the restore process on my testboard. Would that work??
You can enter SQL commands in your Admin section. Scroll to the DB Management table and click on SQL command. Enter the SQL commands that Josh gives in his inctrutions:

Code
 <br />ALTER TABLE w3t_Users <br />ADD U_EmailDigest VARCHAR( 3 ) DEFAULT 'no' NOT NULL <br />


...then click Submit.
I'd suggest you use the Save as File option when backing up in phpMyAdmin and it'll save it as a zip file. I believe this is a fairly new feature, though. Is your host running 2.5.2? If not, you can install your own version. And WinZip can be used for free.

http://winzip.com/ddchomea.htm
thanks for the info...my understanding is that the database management section in threads can't be used on a lot of sites, including infopop shared hosting...anyway, as noted above, there's an entry box for sql queries...is that where I would enter these commands? That's one of the things I was trying to clarify!

ok on winzip...somehow I thought that the evaluation version had a 30-day limit...

FInally...can I confirm that the scheme I outlined above can be used to check that the backup is valid...i.e., by backing up the tables from my MAIN board, changing the prefixes to the one for the TEST board, and then restoring that, and checking to see if the data was usable by the test board?

Thanks - Tony
also note -

It's OK to give this a try - but I have not tested or updated for 6.3..... and recently have LOADS of work on my plate.... so I won't have time to update this for a while unless a client needs it in the meantime.

So just in case it doesn't work - be sure you have your backup scripts so you can roll back.
Yes, there's a box in the admin section, just follow the path I laid out for you to get to it.

And nope, you can use WinZip for free for as long as you like.

You could test it by installing a back-up board, but that would be a lot of work. Really, all you have to do is check the date and size of the file(s) and give the sql file(s) a once over and look at them to see if they look right. Compare your database size to the file size. I believe they should be the same. Also, backups work for some shared servers. They work for mine. To check, after you backup in Threads, check the restore section for the date/size information. If it displays that day's date and the right file sizes (>0) then it should be okay.
Josh:

"but I have not tested or updated for 6.3"

I've had it running on our site for a couple months now and it seems to be working fine. This is a great MOD!
Thanks.

Patrick actually wrote to me and said that on larger forums, this can slow down. I didn't write the original workings to this, as it's based on Lunatik's Subscriber Emailer Hack. I simply used it and added a "switch" to allow people do get either digest or subscription.

The original hack uses a query which Patrick's host told him was pretty inefficient.

$query = "
SELECT U_Email,
U_Language
FROM {$config['tbprefix']}Users
LEFT JOIN {$config['tbprefix']}Subscribe ON S_UID = U_Number
WHERE S_UID = U_Number
AND S_Board = '$Board_q'
AND U_EmailDigest = 'no'
";


Can anyone see a way that the query might be done so that it's faster to complete the post on larger boards?

I'm really not familiar with the use of LEFT JOIN so I'm not sure if that's good or not. LOL

Thanks.

Try this:

SELECT U_Email, U_Language FROM {$config['tbprefix']}Subscribe
LEFT JOIN {$config['tbprefix']}Users ON U_Number = S_Uid
WHERE S_Board = '$Board_q' AND U_EmailDigest = 'no'
Dave/Josh:

Looks like a SLIGHT improvement...

Now - Generated in 19.656 seconds in which 0.149 seconds were spent on a total of 19 queries

Before - Generated in 176.773 seconds in which 159.889 seconds were spent on a total of 16 queries.

THANKS!!!
Yeah, I would say that counts as an improvement.
The Digest or Instant Subscriptions 1.0 Hack is exactly what I need. Thanks for posting it, Josh.

I tried it with my board running 6.4.1.

However, when I tried to reply to a message to see if it worked, I got the following error:

Fatal error: Call to undefined function: headers() in e:\inetpub\wwwroot\ubbthreads\addpost.php on line 1024

This error happens in the new code I added from the hack. The bit of code is:

$to = $Mailto;
$mailer = new mailer;
$header = $mailer -> headers();
$subject = "New Post To $Title from $postername";

I wonder what went wrong there. Does anyone know if this hack will work on a 6.4.1 board?

Thanks,

Geoff
It would need to be rewritten a bit - as the mail function was rewritten in 6.4 so the headers() function no longer exists. It's all been moved into a send_mail function.
Oh, I see.

(Now I'm down on both knees begging):

Any chance you could update the hack?

My users are going nuts asking for this functionality.

You would be my hero!

Thanks,

Geoff
I'll add it to my list - shouldn't be too tough to update. Got some other projects to finish first though.
Thanks so much. I really, really appreciate it.

You don't know me, but your posts here and on the ubbcentral boards have been key for helping me get my board up and running and fully tweaked out.

Your helpful posts are everywhere. I swear they're must be five of you!

Thanks again,

Geoff
LOL

Sometimes I wish there were 5 of me - then I could really get something done.

Thanks,
Josh
Hey Josh.

I was able to make a small modification to your instructions and I got this mod to work with 6.4.2.

All I did was remove the following line from the modified code for addpost.php:

$header = $mailer -> headers();

Then I replaced the old call for sending mail:

mail("$to","$subject",$msg,$header);

with the new call:

$mailer -> send_mail($emailformat,"",$to,$subject,$msg);

and lo and behold everything worked! So now my users (who want it) are getting instant email notification on all posts in the Forums they are interested in.

Thanks a ton for posting this original mod. I'm loving 6.4.2 and now my users are too.

Take care,

Geoff
Yup - you got it -

Great!
© UBB.Developers