You are here

function _better_messages_is_visible in Better Messages 7.2

Helper function to process valid path visiblity along with user access.

1 call to _better_messages_is_visible()
theme_better_messages in ./better_messages.module
Theme function that switches default Drupal messages with Better Messages.

File

./better_messages.module, line 121

Code

function _better_messages_is_visible() {
  $settings = _better_messages_get_settings();
  $visibility = $settings['visibility'];
  if ($visibility['pages']) {

    // Convert path to lowercase. This allows comparison of the same path
    // with different case. Ex: /Page, /page, /PAGE.
    $pages = drupal_strtolower($visibility['pages']);
    if ($visibility['visibility'] < 2) {

      // Convert the Drupal path to lowercase
      $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));

      // Compare the lowercase internal and lowercase path alias (if any).
      $page_match = drupal_match_path($path, $pages);
      if ($path != $_GET['q']) {
        $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
      }
      $page_match = !($visibility['visibility'] xor $page_match);
    }
    elseif (module_exists('php')) {
      $page_match = php_eval($visibility['pages']);
    }
    else {
      $page_match = FALSE;
    }
  }
  else {
    $page_match = TRUE;
  }
  return $page_match && user_access('access better messages');
}