You are here

function skinr_rule_visible in Skinr 6.2

1 call to skinr_rule_visible()
page_skinr_preprocess_index_handler in modules/skinr.skinr.inc
Skinr preprocess index handler.

File

./skinr.module, line 347

Code

function skinr_rule_visible($rid) {
  global $user;
  if ($rule = skinr_rule_load($rid)) {
    $page_match = TRUE;
    if (!empty($record['roles']) && $user->uid != 1 && !count(array_intersect(array_keys($user->roles), $rule->roles))) {
      return FALSE;
    }

    // Match path if necessary
    if ($rule->pages) {
      if ($rule->visibility < 2) {
        $path = drupal_get_path_alias($_GET['q']);

        // Compare with the internal and path alias (if any).
        $page_match = drupal_match_path($path, $rule->pages);
        if ($path != $_GET['q']) {
          $page_match = $page_match || drupal_match_path($_GET['q'], $rule->pages);
        }

        // When $rule->visibility has a value of 0, the item is displayed on
        // all pages except those listed in $rule->pages. When set to 1, it
        // is displayed only on those pages listed in $rule->pages.
        $page_match = !($rule->visibility xor $page_match);
      }
      else {

        // PHP.
        $page_match = drupal_eval($rule->pages);
      }
    }
    return $page_match;
  }
  return FALSE;
}