Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-05-2005, 06:21 AM
hardwareirc.com hardwareirc.com is offline
 
Join Date: Jun 2002
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to decode user options

Hello,
I would like to use my forum for mailing list purposes too, and I want to send emails only to the members that have the "Receive emails" option enabled.

I looked on the vbulletin 3 database, and I saw that the user options preferences are coded with a number, so it's quite difficult to see which number represents the desire to receive emails...

Can anyone help me "decoding" the number?

Thanks
Reply With Quote
  #2  
Old 06-05-2005, 10:18 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The user options are just a bitfield.
From init.php
PHP Code:
// Defined constants used for user field.
$_USEROPTIONS = array(
    
'showsignatures'    => 1,
    
'showavatars'       => 2,
    
'showimages'        => 4,
    
'coppauser'         => 8,
    
'adminemail'        => 16

So if you want to get all users which have this options enabled;:

[sql]SELECT username, email FROM user WHERE options & 16[/sql]
Reply With Quote
  #3  
Old 06-05-2005, 05:04 PM
hardwareirc.com hardwareirc.com is offline
 
Join Date: Jun 2002
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
The user options are just a bitfield.
From init.php
PHP Code:
// Defined constants used for user field.
$_USEROPTIONS = array(
    
'showsignatures'    => 1,
    
'showavatars'       => 2,
    
'showimages'        => 4,
    
'coppauser'         => 8,
    
'adminemail'        => 16

So if you want to get all users which have this options enabled;:

[sql]SELECT username, email FROM user WHERE options & 16[/sql]
Great
It works fine
Reply With Quote
  #4  
Old 06-08-2005, 11:01 AM
hardwareirc.com hardwareirc.com is offline
 
Join Date: Jun 2002
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi guys, I'm not familiar with bitfields... There's a way to set the bit #16 to 0 with just a mysql query?

Thanks
Reply With Quote
  #5  
Old 06-08-2005, 12:16 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes. Bit #16 = 2^15 = 32768
[sql]UPDATE table SET field=field-32768 WHERE field & 32768[/sql]

Or to set it where it is not set
[sql]UPDATE table SET field=field+32768 WHERE NOT (field & 32768)[/sql]
Reply With Quote
  #6  
Old 06-08-2005, 12:22 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Except, I think he means the bit valued at 16, not the 16th bit . In the above options case the value should be 16.
Reply With Quote
  #7  
Old 06-08-2005, 12:26 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

But he said bit #16
Reply With Quote
  #8  
Old 06-08-2005, 12:28 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
But he said bit #16
Technically Yes, because he doesn't understand bit fields - read the posts and I think you will agree with me.
Reply With Quote
  #9  
Old 06-08-2005, 12:48 PM
hardwareirc.com hardwareirc.com is offline
 
Join Date: Jun 2002
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Paul M
Technically Yes, because he doesn't understand bit fields - read the posts and I think you will agree with me.
hmmm... well, could you explain me bitfields in order to avoid any further doubts? :P

or where could I find more info? google doesn't help
Reply With Quote
  #10  
Old 06-08-2005, 12:54 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Correct me if I'm wrong - but you want to set the 'adminemail' option (which is bit 5, value 16) to zero ?
Reply With Quote
Reply

Thread Tools
Display Modes

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:15 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.05903 seconds
  • Memory Usage 2,249KB
  • 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
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete