diff options
Diffstat (limited to 'modules/user/user.module')
-rw-r--r-- | modules/user/user.module | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/modules/user/user.module b/modules/user/user.module index e5c5ecbc6..2140adc28 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -3200,3 +3200,92 @@ function _user_password_dynamic_validation() { $complete = TRUE; } } + + + +/** + * Implementation of hook_hook_info(). + */ +function user_hook_info() { + return array( + 'user' => array( + 'user' => array( + 'insert' => array( + 'runs when' => t('When a user account has been created'), + ), + 'update' => array( + 'runs when' => t('When a user account has been updated'), + ), + 'delete' => array( + 'runs when' => t('When a user account has been deleted') + ), + 'login' => array( + 'runs when' => t('When a user has logged in') + ), + 'logout' => array( + 'runs when' => t('When a user has logged out') + ), + 'view' => array( + 'runs when' => t("When a user's account information is displayed") + ), + ), + ), + ); +} + +/** + * Implementation of hook_action_info(). + */ +function user_action_info() { + return array( + 'user_block_user_action' => array( + 'description' => t('Block current user'), + 'type' => 'user', + 'configurable' => FALSE, + 'hooks' => array( + 'nodeapi' => array('presave', 'delete','insert', 'update','view'), + 'comment' => array('view', 'insert', 'update', 'delete'), + 'user' => array('logout'), + ), + ), + 'user_block_ip_action' => array( + 'description' => t('Ban IP address of current user'), + 'type' => 'user', + 'configurable' => FALSE, + 'hooks' => array( + 'nodeapi' => array('presave', 'delete','insert', 'update','view'), + 'comment' => array('view', 'insert', 'update', 'delete'), + 'user' => array('logout'), + ) + ) + ); +} + +/** + * Implementation of a Drupal action. + * Blocks the current user. + */ +function user_block_user_action(&$object, $context = array()) { + if (isset($object->uid)) { + $uid = $object->uid; + } + elseif (isset($context['uid'])) { + $uid = $context['uid']; + } + else { + global $user; + $uid = $user->uid; + } + db_query("UPDATE {users} SET status = 0 WHERE uid = %d", $uid); + sess_destroy_uid($uid); + watchdog('action', 'Blocked user %name.', array('%name' => check_plain($user->name))); +} + +/** + * Implementation of a Drupal action. + * Adds an access rule that blocks the user's IP address. + */ +function user_block_ip_action() { + db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $_SERVER['REMOTE_ADDR'], 'host', 0); + watchdog('action', 'Banned IP address %ip', array('%ip' => $_SERVER['REMOTE_ADDR'])); +}
\ No newline at end of file |