disable_messages.install 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. * @file
  4. * Filter Messages Module install file
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function disable_messages_install() {
  10. variable_set('disable_messages_enable', '1');
  11. variable_set('disable_messages_ignore_patterns', '');
  12. variable_set('disable_messages_ignore_regex', array());
  13. variable_set('disable_messages_ignore_case', '1');
  14. variable_set('disable_messages_filter_by_page', 0);
  15. variable_set('disable_messages_page_filter_paths', '');
  16. variable_set('disable_messages_exclude_users', '');
  17. variable_set('disable_messages_enable_debug', '0');
  18. variable_set('disable_messages_debug_visible_div', '0');
  19. // Add the access message permission to all roles.
  20. $result = db_query('SELECT r.rid FROM {role} r');
  21. foreach ($result as $role) {
  22. // Add view all message permission for all users.
  23. $permissions = array('view status messages', 'view warning messages', 'view error messages');
  24. foreach ($permissions as $perm) {
  25. db_query("
  26. INSERT INTO {role_permission} (rid, permission, module)
  27. VALUES (:rid, :perm, :module)
  28. ",
  29. array(
  30. ':rid' => $role->rid,
  31. ':perm' => $perm,
  32. ':module' => 'disable_messages',
  33. )
  34. );
  35. }
  36. }
  37. drupal_set_message(st('Added view all message type permissions for all roles. You can change this in !link', array('!link' => l(st('administer permissions'), 'admin/people/permissions', array('fragment' => 'module-disable_messages')))));
  38. }
  39. /**
  40. * Implements hook_uninstall().
  41. */
  42. function disable_messages_uninstall() {
  43. variable_del('disable_messages_enable');
  44. variable_del('disable_messages_ignore_patterns');
  45. variable_del('disable_messages_ignore_regex');
  46. variable_del('disable_messages_ignore_case');
  47. variable_del('disable_messages_filter_by_page');
  48. variable_del('disable_messages_page_filter_paths');
  49. variable_del('disable_messages_exclude_users');
  50. variable_del('disable_messages_enable_debug');
  51. variable_del('disable_messages_debug_visible_div');
  52. // Permission deletions are handled by core
  53. }
  54. /**
  55. * Implementation of hook_update().
  56. */
  57. function disable_messages_update_7100() {
  58. // Do nothing other than force update of theme registry.
  59. }