vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=297249

UserCP email options database locations
by smirkley
15 Apr 2013 23:31

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 16 Apr 2013 04:26

and what are you trying to change to do with these

smirkley 16 Apr 2013 14:37

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 16 Apr 2013 15:13

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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


and to set it to no,

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


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 17 Apr 2013 00:38

Thank you.

Sincerely

kh99 17 Apr 2013 11:17

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 18 Apr 2013 13:45

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 18 Apr 2013 15:05

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 18 Apr 2013 15:06

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 18 Apr 2013 16:16

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 00:56.

Powered by vBulletin® Version 3.8.14
Copyright © 2021, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.