vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   UserCP email options database locations (https://vborg.vbsupport.ru/showthread.php?t=297249)

smirkley 04-15-2013 10:31 PM

UserCP email options database locations
 
I have searched thru the code, and searched through phpmyadmin in the database, and I dont understand where the usercp options for things like 'Receive Email from Administrators' and
'Receive Friendship Request Email' checkbox data is stored.

I thought I found it under 'users', 'options' in the database, but it was just a set of numbers that I couldnt resolve to meaning anything.

If that was the place, is there a list of the codes somewhere out here that would show me what to change those numbers to if I wanted to change the settings via query?

Or if that isnt the place, someone smak me in the head and show me how dense I have become in not seeing it.

Thanks.

ForceHSS 04-16-2013 03:26 AM

and what are you trying to change to do with these

smirkley 04-16-2013 01:37 PM

I have an sql query in another area that I wish to use for automatic changing of certain checkboxes in usercp such as admin emails, subscription notifications, etc.

And I have looked and looked and cant for the life of me find the exact database location for certain settings such as these.

Or I have gone blind and cant find the haystack with the needle in it.

kh99 04-16-2013 02:13 PM

The options column of the user table is a bit field - if you were to write the value in binary, each 0 or 1 would indicate the state of a setting. To change them with a query, you would add or subtract out the value for that option (after making sure the option isn't already in the state you want). For example, to set "Receive Admin Emails" to Yes for everyone who doesn't have it set already, you could do this:
Code:

UPDATE user SET options = options + 16 WHERE NOT (options & 16)

and to set it to no,
Code:

UPDATE user SET options = options - 16 WHERE options & 16

So the next question is, where does the mask value (16) come from? They are defined in the file includes/xml/bitfield_vbulletin.xml. For the user options field, search for <group name="useroptions">. The values (in base 10) might look like random numbers, but in binary they each have only one bit set. You still have to figure out which ones correspond to which options, but hopefully most are obvious, or else you might be able to figure it out by comparing the name in the xml file to the html name attribute of the <input> tag on a page where that option is set.

smirkley 04-16-2013 11:38 PM

Thank you.

Sincerely

kh99 04-17-2013 10:17 AM

Another thing I didn't mention - if you're writing code to set the options, you should use the values that get read in from the xml file instead of hard-coding numbers. For example, $vbulletin->bf_misc_useroptions['adminemail'] would be set to 16.

smirkley 04-18-2013 12:45 PM

Quote:

Originally Posted by kh99 (Post 2416672)
....(after making sure the option isn't already in the state you want).

Because this sounds like to me that you are saying I need to verify the state first before modifying the state (if I understand what you are saying, it is because you are adding/subtracting data values from a sum), do you have a recommended method?

I am thinking I need to do an if/else...or just an if...


If...

State is off, set to on


or vs/vs

kh99 04-18-2013 02:05 PM

Yeah, well, I should probably have stressed that you need to do the check if you're going to set/reset the bits using addition and subtraction, because it may be tempting to think that since you want to set it for everyone, you could just remove the WHERE. But if you do that it won't work and it will affect other options. There are "bitwise" operators that you could use to set/reset bits with no check and without affecting any other options, but the reason my example didn't use those is because I copied those queries from the Automatic Query section of Maintenance > Execute SQL Query in the admincp, and I didn't want to suggest that you could do it a different way unless I tested it (and I'm kind of a novice level SQL person).

kh99 04-18-2013 02:06 PM

Quote:

Originally Posted by smirkley (Post 2417128)
Because this sounds like to me that you are saying I need to verify the state first before modifying the state (if I understand what you are saying, it is because you are adding/subtracting data values from a sum), do you have a recommended method?

I am thinking I need to do an if/else...or just an if...


If...

State is off, set to on


or vs/vs


Oh, I guess I didn't really answer this - sounds like you figured out that it's because of the add/subtract. So I guess the answer to your question is that the check is taken care of in those queries by the WHERE clause, so you don't need to add any other check. Maybe I made it more confusing by mentioning that, but like I said above, I was concerned that you might have decided the WHERE wasn't needed.

smirkley 04-18-2013 03:16 PM

Well I know I am not the sql wizzard,.. I should have seen that.

Thanks again. (tried to like, but vborg says I liked you too much lol)


All times are GMT. The time now is 02:59 AM.

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.01041 seconds
  • Memory Usage 1,737KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete