Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jun 2002
Posts: 27
User
User
Offline
Joined: Jun 2002
Posts: 27
I added some code that will allow for people to use the subscription option to get email on new posts when they get submitted instead of the daily report.

Modify your addpost.php and goto
// ---------------------------------------------
// Update the total post if the post is Approved
if ($Approved == "yes") {


and add this code right above
code:

// Send an Email to the Subscribers if they are Subscribed to this board
if ($Approved == "yes") {
$query = "
SELECT U_Email,
U_Language
FROM w3t_Users
LEFT JOIN w3t_Subscribe ON U_Username = S_Username
WHERE S_Username = U_Username
AND S_Board = '$Board_q'
";

$sth = $dbh -> do_query($query);

while ( list($Mailto,$Language) = $dbh -> fetch_array($sth) ) {
// -------------------------------------------=
// We need to make sure this user still exists
if ($Mailto) {

// -----------------------------------------------------------------
// Now if this user has a pre-selected language we use that language
// for the message we send out
if (!$Language) { $Language = $config['language'];}
require "{$config['path']}/languages/$Language/addpost.php";

$EmailBody = $Body;
if ($config['stripcodes']) {
$EmailBody = preg_replace("/<([^>])*>/","",$EmailBody);
}

$newline = "\n";
if (stristr(PHP_OS,"win")) {
$newline = "\r\n";
}

$to = $Mailto;
$mailer = new mailer;
$header = $mailer -> headers();
$subject = "New Post To $Title from $postername";
$msg = "$postername has posted a message to $Title: $newline{$config['phpurl']}/showthreaded.php?Cat=$Cat&Board=$Board&Number=$Mnumber$newline${newline}------Message Below------${newline}Subject: $FormSubject${newline}${newline}Message:$newline$EmailBody";

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

// --------------------------------------------------
// Now, we need to switch back to this users language
$Language = $user['U_Language'];
if (!$Language) { $Language = $config['language']; }
require "{$config['path']}/languages/$Language/addpost.php";
}
}
}


Last edited by Lunatik; 06/20/2002 12:20 PM.
Sponsored Links
Joined: Jun 2002
Posts: 27
User
User
Offline
Joined: Jun 2002
Posts: 27
Also you might want to modify the editemail.php in the languages directory and change the line

$ubbt_lang['SUB_STAT'] = "Subscription status for the following forums. (Receive a daily archive of all posts to this forum via your Real email address.)";

to

$ubbt_lang['SUB_STAT'] = "Subscription status for the following forums. (Receive an email on all posts to this forum via your Real email address.)";

Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
good one Often requested...

question, can it be turned off? Would hate to subscribe to a question/answer thread and it go on for 3-400 pages


- Allen wavey
- What Drives You?
Joined: Jun 2002
Posts: 27
User
User
Offline
Joined: Jun 2002
Posts: 27
The way it is designed the user can go to "My Home" and unsubscribe to the board at anytime. Or if you wish to shut the whole thing down just edit your config and turn off subscriptions.

The only thing I have to check on is if you turn off subscriptions does it clear the subscription table. Might have to look into that one.

Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
ok, sounds good then


- Allen wavey
- What Drives You?
Sponsored Links
Joined: Jun 2002
Posts: 27
User
User
Offline
Joined: Jun 2002
Posts: 27
I did some testing. When you turn off subscriptions in the config settings it does not remove the users from the subscribe table, however it still sends an email to the people who are subscribed to the board.

I will add something to the code so that if the subscriptions is turned off it will quit sending emails on all posts.

Last edited by Lunatik; 06/21/2002 10:46 PM.
Joined: Jun 2002
Posts: 27
User
User
Offline
Joined: Jun 2002
Posts: 27
Here is the updated code for the subscriptions. If you globally disable subscriptions it will not send an email out.

code:

// Send an Email to the Subscribers if they are Subscribed to this board
if (($Approved == "yes") && ($config['subscriptions'] == 1)){
$query = "
SELECT U_Email,
U_Language
FROM w3t_Users
LEFT JOIN w3t_Subscribe ON U_Username = S_Username
WHERE S_Username = U_Username
AND S_Board = '$Board_q'
";

$sth = $dbh -> do_query($query);

while ( list($Mailto,$Language) = $dbh -> fetch_array($sth) ) {
// -------------------------------------------=
// We need to make sure this user still exists
if ($Mailto) {

// -----------------------------------------------------------------
// Now if this user has a pre-selected language we use that language
// for the message we send out
if (!$Language) { $Language = $config['language'];}
require "{$config['path']}/languages/$Language/addpost.php";

$EmailBody = $Body;
if ($config['stripcodes']) {
$EmailBody = preg_replace("/<([^>])*>/","",$EmailBody);
}

$newline = "\n";
if (stristr(PHP_OS,"win")) {
$newline = "\r\n";
}

$to = $Mailto;
$mailer = new mailer;
$header = $mailer -> headers();
$subject = "New Post To $Title from $postername";
$msg = "$postername has posted a message to $Title: $newline{$config['phpurl']}/showthreaded.php?Cat=$Cat&Board=$Board&Number=$Mnumber$newline${newline}------Message Below------${newline}Subject: $FormSubject${newline}${newline}Message:$newline$EmailBody";

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

// --------------------------------------------------
// Now, we need to switch back to this users language
$Language = $user['U_Language'];
if (!$Language) { $Language = $config['language']; }
require "{$config['path']}/languages/$Language/addpost.php";
}
}
}


Joined: Jun 2002
Posts: 27
User
User
Offline
Joined: Jun 2002
Posts: 27
I tested this with Version 6.0.2 and everything appears to be working the same without any furter modifications.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)