You are here

errorlevelpermission.module in Error Level Permission 7

Same filename and directory in other branches
  1. 8 errorlevelpermission.module

File

errorlevelpermission.module
View source
<?php

/**
 * @file errorlevelpermission.module
 */

/**
 * Implements hook_permission().
 */
function errorlevelpermission_permission() {
  return array(
    'errorlevelpermission show errors' => array(
      'title' => t('Show errors and warnings'),
    ),
    'errorlevelpermission show all' => array(
      'title' => t('Show errors, warnings and notices'),
    ),
  );
}

/**
 * Implements hook_init().
 */
function errorlevelpermission_init() {
  global $conf;

  // Care that no errors are shown before we take control.
  if (!empty($conf['error_level'])) {
    variable_set('error_level', ERROR_REPORTING_HIDE);
  }

  // Take over control.
  $level = user_access('errorlevelpermission show all') ? ERROR_REPORTING_DISPLAY_ALL : (user_access('errorlevelpermission show errors') ? ERROR_REPORTING_DISPLAY_SOME : ERROR_REPORTING_HIDE);

  // No need to waste DB writes via variable_set().
  $conf['error_level'] = $level;
}

/**
 * Implements hook_form_FORM_ID_alter() for system_logging_settings().
 */
function errorlevelpermission_form_system_logging_settings_alter(&$form, &$form_state, $form_id) {
  $form['error_level'] = array(
    '#type' => 'item',
    '#title' => t('Error messages to display'),
    '#description' => t('Error Level Permission module took this over with <a href="@link">its permissions</a>.', array(
      '@link' => url('admin/people/permissions', array(
        'fragment' => 'module-errorlevelpermission',
      )),
    )),
  );
}