You are here

function drupalchat_verify_access in DrupalChat 6.2

Same name and namespace in other branches
  1. 7.2 drupalchat.module \drupalchat_verify_access()
  2. 7 drupalchat.module \drupalchat_verify_access()
2 calls to drupalchat_verify_access()
drupalchat_footer in ./drupalchat.module
Implementation of hook_footer().
drupalchat_init in ./drupalchat.module

File

./drupalchat.module, line 37
Module code for DrupalChat.

Code

function drupalchat_verify_access() {
  global $user;
  $sid = _drupalchat_get_sid();

  // Match path if necessary.
  $page_match = FALSE;
  if (variable_get('drupalchat_path_pages', NULL)) {

    // Convert path to lowercase. This allows comparison of the same path
    // with different case. Ex: /Page, /page, /PAGE.
    $pages = drupal_strtolower(variable_get('drupalchat_path_pages', NULL));
    if (variable_get('drupalchat_path_visibility', 0) < 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 $block->visibility has a value of 0 (BLOCK_VISIBILITY_NOTLISTED),
      // the block is displayed on all pages except those listed in $block->pages.
      // When set to 1 (BLOCK_VISIBILITY_LISTED), it is displayed only on those
      // pages listed in $block->pages.
      $page_match = !(variable_get('drupalchat_path_visibility', 0) xor $page_match);
    }
    elseif (module_exists('php')) {
      $page_match = drupal_eval(variable_get('drupalchat_path_pages', NULL));
    }
    else {
      $page_match = FALSE;
    }
  }
  else {
    $page_match = TRUE;
  }
  return (variable_get('drupalchat_rel', DRUPALCHAT_REL_AUTH) == DRUPALCHAT_REL_AUTH && $user->uid == 0 || $user->uid > 0) && $page_match && user_access('access drupalchat') && $sid != -1;
}