You are here

function disable_messages_install in Disable Messages 7

Same name and namespace in other branches
  1. 8 disable_messages.install \disable_messages_install()
  2. 6 disable_messages.install \disable_messages_install()
  3. 2.x disable_messages.install \disable_messages_install()

Implements hook_install().

File

./disable_messages.install, line 11
Filter Messages Module install file.

Code

function disable_messages_install() {
  variable_set('disable_messages_enable', '1');
  variable_set('disable_messages_ignore_patterns', '');
  variable_set('disable_messages_ignore_regex', array());
  variable_set('disable_messages_ignore_case', '1');
  variable_set('disable_messages_filter_by_page', 0);
  variable_set('disable_messages_page_filter_paths', '');
  variable_set('disable_messages_exclude_users', '');
  variable_set('disable_messages_enable_debug', '0');
  variable_set('disable_messages_debug_visible_div', '0');

  // Add the access message permission to all roles.
  $result = db_query('SELECT r.rid FROM {role} r');
  foreach ($result as $role) {

    // Add view all message permission for all users.
    $permissions = array(
      'view status messages',
      'view warning messages',
      'view error messages',
    );
    foreach ($permissions as $perm) {
      db_query("\n        INSERT INTO {role_permission} (rid, permission, module)\n          VALUES (:rid, :perm, :module)\n        ", array(
        ':rid' => $role->rid,
        ':perm' => $perm,
        ':module' => 'disable_messages',
      ));
    }
  }
  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',
    )),
  )));
}