function _absolute_messages_visibility_pages in Absolute Messages 7
Same name and namespace in other branches
- 6 absolute_messages.module \_absolute_messages_visibility_pages()
 
Based on visibility setting this function returns TRUE if AM should be enabled on the current page or FALSE otherwise.
1 call to _absolute_messages_visibility_pages()
- theme_absolute_messages in ./
absolute_messages.module  - Theme function, overriding Drupal's theme_status_messages().
 
File
- ./
absolute_messages.module, line 259  - Module displaying system messages in colored horizontal bars on top of the page, similar to Stack Overflow / Stack Exchange network notifications.
 
Code
function _absolute_messages_visibility_pages() {
  static $page_match;
  // Cache visibility result if function is called more than once.
  if (!isset($page_match)) {
    $visibility = variable_get('absolute_messages_visibility_pages', 0);
    $setting_pages = variable_get('absolute_messages_pages', NULL);
    // Match path if necessary.
    if (!empty($setting_pages)) {
      // Convert path to lowercase. This allows comparison of the same path
      // with different case. Ex: /Page, /page, /PAGE.
      $pages = drupal_strtolower($setting_pages);
      if ($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);
        }
        // When $visibility has a value of 0, Absolute Messages is enabled
        // on all pages except those listed in $pages. When set to 1,
        // it is enabled only on those pages listed in $pages.
        $page_match = !($visibility xor $page_match);
      }
      elseif (module_exists('php')) {
        $page_match = php_eval($setting_pages);
      }
      else {
        $page_match = FALSE;
      }
    }
    else {
      $page_match = TRUE;
    }
  }
  return $page_match;
}