View Full Version : I need some help with this if/else statement
Parker Clack
03-21-2002, 10:15 PM
I have added the option in the User Control Panel to select whether or not you want an email response each time some one replies to a thread you have requested email notifications on or just the one time (as is vBulletin's default).
I have added a row to the User table called allemail and then
in the email notification section of the functions.php file I added
if ($bbuserinfo['allemail']==0) {
$useremails=$DB_site->query("SELECT user.*
FROM subscribethread,user
WHERE subscribethread.threadid='$threadid'
AND subscribethread.userid=user.userid
AND user.userid<>'$userid'
AND user.lastactivity>'$lastposttime[dateline]'");
} else {
$useremails=$DB_site->query("SELECT user.*
FROM subscribethread,user
WHERE subscribethread.threadid='$threadid'
AND subscribethread.userid=user.userid
AND user.userid<>'$userid'");
}
When they select "No" the value is zero and they should just get one response. If "Yes" they should get a response each time. As
it is working now though they get a response each time. So it appears to me that the if statement isn't working and it just defaults to the last statement. Allemail is getting set to 1 or 0 just fine from the user control panel but the script does not appear to recognize the if else routine.
Any ideas on how to get this to work?
Thanks,
Parker
Mark Hensler
03-22-2002, 04:35 AM
simple debuging skills... "When in doubt, print it out." ;)
print the value of $bbuserinfo['allemail']
Parker Clack
03-22-2002, 08:11 AM
Mark:
Sorry, I am not the great of a coder. How would I go about printing this out?
Parker
Admin
03-22-2002, 10:24 AM
Is $bbuserinfo available in that function?
Parker Clack
03-22-2002, 12:18 PM
Chen:
It should be. Here is a bit more of the code in question as I have it written into the existing code.
....$lastposttime=$DB_site->query_first("SELECT dateline
FROM post
WHERE threadid='$threadid'
ORDER BY dateline DESC
LIMIT ".iif($moderated, '1,1', '1'));
// if it's moderated, the post has already been inserted, so we want the one before that
if ($bbuserinfo['allemail']==0) {
$useremails=$DB_site->query("SELECT user.*
FROM subscribethread,user
WHERE subscribethread.threadid='$threadid'
AND subscribethread.userid=user.userid
AND user.userid<>'$userid'
AND user.lastactivity>'$lastposttime[dateline]'");
} else {
$useremails=$DB_site->query("SELECT user.*
FROM subscribethread,user
WHERE subscribethread.threadid='$threadid'
AND subscribethread.userid=user.userid
AND user.userid<>'$userid'");
}
$threadinfo[title]=unhtmlspecialchars($threadinfo['title']);
$temp = $bbuserinfo['username'];
if ($postid) {
$postinfo = getpostinfo($postid);
$bbuserinfo['username'] = unhtmlspecialchars($postinfo['username']);
$bbuserinfo['email'] = unhtmlspecialchars($postinfo['email']);
$postemail = $bbuserinfo['email'];
} else {
if (!$bbuserinfo['userid']) {
$bbuserinfo['username'] = unhtmlspecialchars($postusername);
$bbuserinfo['email'] = unhtmlspecialchars($postuseremail);
$postemail = $bbuserinfo['email'];
} else {
$bbuserinfo['username'] = unhtmlspecialchars($bbuserinfo['username']);
$bbuserinfo['email'] = unhtmlspecialchars($bbuserinfo['email']);
$postemail = $bbuserinfo['email'];
}
}
while ($touser=$DB_site->fetch_array($useremails)) {
$touser['username']=unhtmlspecialchars($touser['username']);
............................................
Since bbuserinfo userid, email, username are available and allemail in in the same user table I would think that it would be called up with no problem too.
Any ideas?
Parker
Admin
03-22-2002, 12:33 PM
Oh ok I see the problem now, you are coding this the wrong way.
Replace this:
$useremails=$DB_site->query("SELECT user.*
FROM subscribethread,user
WHERE subscribethread.threadid='$threadid'
AND subscribethread.userid=user.userid
AND user.userid<>'$userid'
AND user.lastactivity>'$lastposttime[dateline]'");
$useremails=$DB_site->query("SELECT user.*
FROM subscribethread,user
WHERE subscribethread.threadid='$threadid'
AND subscribethread.userid=user.userid
AND user.userid<>'$userid'");
And add this:
if (!$touser['allemail'] and $touser['lastactivity']<=$lastposttime['dateline'])
continue;
Right after this:
while ($touser=$DB_site->fetch_array($useremails)) {
Parker Clack
03-22-2002, 12:50 PM
Ok so I would end up with
$lastposttime=$DB_site->query_first("SELECT dateline
FROM post
WHERE threadid='$threadid'
ORDER BY dateline DESC
LIMIT ".iif($moderated, '1,1', '1'));
// if it's moderated, the post has already been inserted, so we want the one before that
$useremails=$DB_site->query("SELECT user.*
FROM subscribethread,user
WHERE subscribethread.threadid='$threadid'
AND subscribethread.userid=user.userid
AND user.userid<>'$userid'");
$threadinfo[title]=unhtmlspecialchars($threadinfo['title']);
$temp = $bbuserinfo['username'];
if ($postid) {
$postinfo = getpostinfo($postid);
$bbuserinfo['username'] = unhtmlspecialchars($postinfo['username']);
$bbuserinfo['email'] = unhtmlspecialchars($postinfo['email']);
$postemail = $bbuserinfo['email'];
} else {
if (!$bbuserinfo['userid']) {
$bbuserinfo['username'] = unhtmlspecialchars($postusername);
$bbuserinfo['email'] = unhtmlspecialchars($postuseremail);
$postemail = $bbuserinfo['email'];
} else {
$bbuserinfo['username'] = unhtmlspecialchars($bbuserinfo['username']);
$bbuserinfo['email'] = unhtmlspecialchars($bbuserinfo['email']);
$postemail = $bbuserinfo['email'];
}
}
while ($touser=$DB_site->fetch_array($useremails)) {
if (!$touser['allemail'] and $touser['lastactivity']<=$lastposttime['dateline'])
continue;
Correct?
Thanks,
Parker
Admin
03-22-2002, 01:03 PM
Yes.
Parker Clack
03-22-2002, 01:13 PM
Chen:
Again that did it and again you have helped me out a great deal.
Thanks,
Parker
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.