I am unsure how to restore a user with the user.settings.USER_DELETED or restore a USER_INACTIVE any help would be appreciated
I am unsure how to restore a user with the user.settings.USER_DELETED or restore a USER_INACTIVE any help would be appreciated
Re: User Object USER_DELETED
By: Mortifis to All on Tue Jul 23 2019 12:52:15
I am unsure how to restore a user with the user.settings.USER_DELETED or restore a USER_INACTIVE any help would be appreciated
user.settings &=~ USER_DELETED;
Re: User Object USER_DELETED
By: Mortifis to All on Tue Jul 23 2019 12:52:15
I am unsure how to restore a user with the user.settings.USER_DELETED or restore a USER_INACTIVE any help would be appreciated
user.settings &=~ USER_DELETED;
interesting ... that &=~ ... undeletes?
no wonder USER_DELETED = 0 didn't
work ... thought it was a BOOLEAN o.o
Re: User Object USER_DELETED
By: Mortifis to All on Tue Jul 23 2019 12:52:15
I am unsure how to restore a user with the user.settings.USER_DELETED or restore a USER_INACTIVE any help would be appreciated
user.settings &=~ USER_DELETED;
as learning any language ( obviously I am not C adept) what does ~& or even just ~ mean negate a bitwise?
Re: Re: User Object USER_DELETED
By: Mortifis to echicken on Tue Jul 23 2019 22:40:15
as learning any language ( obviously I am not C adept) what does ~& or even just ~ mean negate a bitwise?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/ Bitwise_Operators
'~a' inverts the bits of 'a'
'a & b' returns ones in positions where both 'a' and 'b' have ones
'a & ~b' returns ones in positions where both 'a' and the inverse of 'b' have ones
'a &= b' assigns the result of 'a & b' to 'a'
'a &= ~b' assigns the result of 'a & ~b' to 'a'
'a | b' returns ones where either 'a' or 'b' have ones
'a |= b' assigns the result of 'a | b' to 'a'
So:
var a = 1; // 00000001
var b = 2; // 00000010
a |= b; // a = 00000001 | 00000010
a &= ~b; // a = 00000011 & 11111101
if that makes sense.
Re: User Object USER_DELETED
By: Mortifis to All on Tue Jul 23 2019 12:52 pm
I am unsure how to restore a user with the user.settings.USER_DELETED or restore a USER_INACTIVE any help would be appreciated
USER_DELETED and USER_INACTIVE are bit flags. An integer can hold many bit flags (typically, 32). In the case of user.settings, each bit as a pre-defined purpose and those bits have been assigned symbolic names (in userdefs.js).
To set (add) a bit-flag, you bit-wise "OR" it into the value, like so:
user.settings |= USER_DELETED;
To unset (remove) a bit-flag, you bit-wise "AND" it with the opposite (bit-wise not) value, like so:
user.settings &= ~USER_DELETED;
Hope that helps,
digital man
Sysop: | Chris Crash |
---|---|
Location: | Huntington Beach, CA. |
Users: | 578 |
Nodes: | 8 (0 / 8) |
Uptime: | 29:17:33 |
Calls: | 10,736 |
Calls today: | 1 |
Files: | 5 |
Messages: | 443,196 |
Posted today: | 1 |