Code: Select all
function thunderfist_user($op, &$edit, &$account, $catagory = NULL) {
global $user;
switch( $op ) {
// The User is Registering
case 'register':
// Add a fieldset containing radio buttons
// to the user registration form.
$fields['wow_client'] = array(
'#type' => 'fieldset',
'#title' => 'WOW Client Selection'
);
$fields['wow_client']['decision'] = array(
'#type' => 'radios',
'#description' => 'Select your WOW client',
'#required' => 'TRUE',
'#default_value' => 1,
'#options' => array( 'WOW', 'WOW - TBC', 'WOW - WOTLK' )
);
return $fields;
break;
// Check for duplicate IP's and deny if found.
case 'validate':
if( !$user->uid ) {
$msg = '';
if( isset( $edit['decision'] ) && $edit['decision'] == '0' ) {
$client_flags = '0';
}
elseif( isset( $edit['decision'] ) && $edit['decision'] == '1' ) {
$client_flags = '8';
}
if( isset( $edit['decision'] ) && $edit['decision'] == '2' ) {
$client_flags = '44';
}
}
return;
break;
// Export form data and create a <span style='color:red;text-decoration:blink' title='Alert a moderator!'>grilled spam</span>
// Grab password before it's encrypted so we can use SHA1
case 'insert':
foreach ( $edit as $key => $value ) {
switch ( $key ) {
case 'pass':
$wowpass = $value;
break;
case 'roles':
if ( $user->uid ) {
$gm = thunderfist_roles( $value );
}
break;
}
}
// Insert account information into the logon database
db_set_active( 'logon' );
db_query( "INSERT INTO TFlogon.accounts (acct, login, password, encrypted_password, gm, lastip, email, flags) values (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
$account->uid, $account->name, $wowpass, SHA1(strtoupper(
$account->name).':'.strtoupper( $wowpass ) ), $gm, $user->hostname,
$account->mail, $user->flags, $client_flags );
db_set_active( 'default' );
db_query( " UPDATE users SET access = %d where uid = %d", time(), $account->uid );
db_set_active( 'default' );
break;
// Update the login, password, banned info, wow client in the logon when user updates drupal information.
case 'update':
if( isset( $edit['name'] ) ) {
$login = $edit['name'];
}
if( isset( $edit['pass'] ) && !empty( $edit['pass'] ) ) {
$newpass = $edit['pass'];
}
if( isset( $edit['decision'] ) ) {
$client_flags = $edit['decision'];
}
else {
db_set_active( 'logon' );
$newpass = db_result( db_query( "SELECT password FROM TFlogon.accounts where acct = %d", $account->uid ) );
db_set_active( 'default' );
}
if( $edit['status'] ) {
$banned = 0;
}
else {
$banned = $edit['status'];
}
if( isset( $edit['roles'] ) ) {
$rid = 0;
foreach( $edit['roles'] as $role ) {
if( $role > $rid ) {
$rid = $role;
}
}
$gm = thunderfist_roles( $rid );
}
else {
$rid = db_result( db_query( "SELECT max(rid) from users_roles where uid = %d", $account->uid ) );
$gm = thunderfist_roles( $rid );
}
thunderfist_updateinfo( $login, $newpass, $gm, $banned, $flags, $account->uid );
break;
// Delete user account from the logon database
case 'delete':
thunderfist_deleteaccount( $account->uid );
break;
}
}