forgotten_login.install 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the Forgotten Login module.
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function forgotten_login_install() {
  10. $spec = array(
  11. 'type' => 'int',
  12. 'size' => 'normal',
  13. 'unsigned' => TRUE,
  14. 'not null' => TRUE,
  15. 'default' => 0,
  16. 'initial' => 0,
  17. );
  18. db_add_field('users', 'forgotten_login_attempts', $spec);
  19. $t = get_t();
  20. $t_args = array('@settings_page_url' => url('admin/config/people/forgotten_login'));
  21. drupal_set_message($t('Forgotten login module has been installed. You will need to visit the <a href="@settings_page_url">settings page</a> to set a login attempts limit before this module will do anything.', $t_args));
  22. }
  23. /**
  24. * Implements hook_uninstall().
  25. */
  26. function forgotten_login_uninstall() {
  27. db_drop_field('users', 'forgotten_login_attempts');
  28. }
  29. /**
  30. * Implements hook_schema_alter().
  31. */
  32. function forgotten_login_schema_alter(&$schema) {
  33. // Add field to existing schema.
  34. $schema['users']['fields']['forgotten_login_attempts'] = array(
  35. 'type' => 'int',
  36. 'size' => 'normal',
  37. 'unsigned' => TRUE,
  38. 'not null' => TRUE,
  39. 'default' => 0,
  40. 'description' => 'How many failed login attempts the user has made.',
  41. );
  42. }