Muppettt
07-30-2007, 12:15 PM
Hey,
I'm currently making a custom usercp (outwith vB but including certain parts/files into it). I'm trying to reproduce the options page and notice vB stores all the option data into a bitfield.
How can i 'decode' the bitfield to show what options a user currently has set? I know i can select the data using
SELECT username, email FROM user WHERE options & 16
so that would display everyone with adminemail set to ON, but how would i make it so that it pulls the options bitfield and 'decode' that to show what features the user currently has ON (as in text outputs - 16 = Receive Admin Emails). I assume there would be an array somewhere with all the pertinent data?
And i assume for UPDATING the user table with the a new adminemail option (if changed) it would be:
UPDATE user SET options = options - 16 WHERE (options & 16) AND userid = 123
I'm currently making a custom usercp (outwith vB but including certain parts/files into it). I'm trying to reproduce the options page and notice vB stores all the option data into a bitfield.
How can i 'decode' the bitfield to show what options a user currently has set? I know i can select the data using
SELECT username, email FROM user WHERE options & 16
so that would display everyone with adminemail set to ON, but how would i make it so that it pulls the options bitfield and 'decode' that to show what features the user currently has ON (as in text outputs - 16 = Receive Admin Emails). I assume there would be an array somewhere with all the pertinent data?
And i assume for UPDATING the user table with the a new adminemail option (if changed) it would be:
UPDATE user SET options = options - 16 WHERE (options & 16) AND userid = 123