ajax_register.install 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the AJAX REGISTER module.
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function ajax_register_install() {
  10. //Make sure we're heavy so our form_alter hook gets executed last.
  11. db_update('system')
  12. ->fields(array('weight' => 1000))
  13. ->condition('name', 'ajax_register')
  14. ->execute();
  15. }
  16. /**
  17. * Implements hook_uninstall().
  18. */
  19. function ajax_register_uninstall() {
  20. db_query("DELETE FROM {variable} WHERE name LIKE 'ajax_register_%'");
  21. cache_clear_all('variables', 'cache_bootstrap');
  22. }
  23. /**
  24. * Make sure we're heavy so our form_alter hook gets executed last.
  25. */
  26. function ajax_register_update_7406() {
  27. db_update('system')
  28. ->fields(array('weight' => 1000))
  29. ->condition('name', 'ajax_register')
  30. ->execute();
  31. }
  32. /**
  33. * Rename existing redirect variables and create new redirect behavior variable from redirect url.
  34. */
  35. function ajax_register_update_7407() {
  36. // Login and register redirect behaviors should initially refresh the page.
  37. // This has always been the default functionality provided by the module.
  38. $login_behavior = 'refresh';
  39. $register_behavior = 'refresh';
  40. // Set the password redirect to none, as this was the default behavior.
  41. $password_behavior = 'none';
  42. // Load the existing variables and then delete them.
  43. $login_redirect_url = variable_get('ajax_register_login_form_redirect', '');
  44. variable_del('ajax_register_login_form_redirect');
  45. if (!empty($login_redirect_url)) {
  46. $login_behavior = 'custom';
  47. }
  48. $register_redirect_url = variable_get('ajax_register_register_form_redirect', '');
  49. variable_del('ajax_register_register_form_redirect');
  50. if (!empty($register_redirect_url)) {
  51. $register_behavior = 'custom';
  52. }
  53. elseif ($register_redirect_url == '<noredirect>') {
  54. $register_behavior = 'none';
  55. $register_redirect_url = '';
  56. }
  57. // Save the new variables.
  58. variable_set('ajax_register_login_redirect_behavior', $login_behavior);
  59. variable_set('ajax_register_register_redirect_behavior', $register_behavior);
  60. variable_set('ajax_register_password_redirect_behavior', $password_behavior);
  61. // Only set the new custom URL redirects if they're not actually empty.
  62. if (!empty($login_redirect_url)) {
  63. variable_set('ajax_register_login_redirect_url', $login_redirect_url);
  64. }
  65. if (!empty($register_redirect_url)) {
  66. variable_set('ajax_register_register_redirect_url', $register_redirect_url);
  67. }
  68. }