Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-21-2002, 10:15 PM
Parker Clack Parker Clack is offline
 
Join Date: Oct 2001
Posts: 351
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default I need some help with this if/else statement

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
Reply With Quote
  #2  
Old 03-22-2002, 04:35 AM
Mark Hensler's Avatar
Mark Hensler Mark Hensler is offline
 
Join Date: Oct 2001
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

simple debuging skills... "When in doubt, print it out."

print the value of $bbuserinfo['allemail']
Reply With Quote
  #3  
Old 03-22-2002, 08:11 AM
Parker Clack Parker Clack is offline
 
Join Date: Oct 2001
Posts: 351
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Mark:

Sorry, I am not the great of a coder. How would I go about printing this out?

Parker
Reply With Quote
  #4  
Old 03-22-2002, 10:24 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is $bbuserinfo available in that function?
Reply With Quote
  #5  
Old 03-22-2002, 12:18 PM
Parker Clack Parker Clack is offline
 
Join Date: Oct 2001
Posts: 351
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Chen:

It should be. Here is a bit more of the code in question as I have it written into the existing code.

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
Reply With Quote
  #6  
Old 03-22-2002, 12:33 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh ok I see the problem now, you are coding this the wrong way.

Replace this:
Code:
  $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]'");
Code:
  $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:
Code:
    if (!$touser['allemail'] and $touser['lastactivity']<=$lastposttime['dateline'])
      continue;
Right after this:
Code:
  while ($touser=$DB_site->fetch_array($useremails)) {
Reply With Quote
  #7  
Old 03-22-2002, 12:50 PM
Parker Clack Parker Clack is offline
 
Join Date: Oct 2001
Posts: 351
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok so I would end up with

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

  $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
Reply With Quote
  #8  
Old 03-22-2002, 01:03 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes.
Reply With Quote
  #9  
Old 03-22-2002, 01:13 PM
Parker Clack Parker Clack is offline
 
Join Date: Oct 2001
Posts: 351
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Chen:

Again that did it and again you have helped me out a great deal.

Thanks,
Parker
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:32 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03798 seconds
  • Memory Usage 2,246KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete