Greetings All!
I was hoping someone might be able to direct me to the appropriate lines of code in the drupal core that tell what value to store in the MySQL database for whether the user account is active or blocked... as well as the accessor method which allows users to log in based on this value...
I would like to create a custom banned page for users, and hence need to store three separate values for user status... $inactive=0, $active=1 $blocked=2... you get the idea... and then based on that info have a php page come up if they are banned that pulls info from another table in MySQL based on their uid that states the reason for their ban...
In actuality I thought I might run some simple perl or python scripts that would handle the banning and unbanning, separated by a sleep function for the duration of the ban...
Can anyone help direct me to those lines? I can handle the code myself, unless you feel like contributing....
Thanks to anyone who responds,
Tim
Comments
RE:
Hi,
You can use global variable $user->status to check whether the user is in good standing (contains 1) or 0 if the user has been blocked.
if $user->status is 0, then redirect to your banned users page, and use $user->uid for the reason of the ban (are u using cck field?)
Well, See, the only problem is...
an unauthenticated user also has the value $user->status==0 and so you don't want to confuse new users to the site by a glaring ban message... although... i suppose actually if the $user->uid doesn't appear in the ban table... then it can send them to the regular registration... but that seems like a lot of overhead to run.... since it would occur everytime a non-authenticated user attempted login... though, i suppose since I have enabled the automatic authentication on sign up this isn't an issue for me... but it seems odd that the drupal core is so non extensible... (i found the appropriate lines) actually checking between hardcoded 0 and 1 rather than $inactive, $active, and $blocked or something useful like that... granted, that variable assignment would happen every time the script ran... but on the machine level it does that regardless as soon as it attempts to do the comparative operation... so.. hmm...
what would be nice would be to have the actual user module assign $user->status = $banned where $banned = 2 when you use the built in gui and check for that in login, as well as redirect...
It also seems odd that there is no check for banning the Admin account... though I'm not silly enough to do this intentionally myself, I have other MODs helping control the forum, or they will when it gets up and running, and they need to be able to manage user accounts, which, incidentally gives them access to banning and or deleting the admin account... I wrote a simple script to re-add the admin account with its appropriate values and one to unblock the account... but it seems silly that there is no checks or balances for this type of thing... only Admin should be able to ban or block admin, regardless of any other user permissions... and the two scripts necessary for undoing those actions should be included with the distro... or at least thats how it seems to me..
but that brings me back to the question of how to integrate this functionality into the user module... or.. how to write a custom ban module that will integrate itself into drupal and run before the rest of the login script....
does anyone know where I should start with those?