You are here

function _asset_page_match in Asset 5

Same name and namespace in other branches
  1. 6 asset.module \_asset_page_match()

Should we show the insert access link, determined by admin setting Borrowed from tinymce.module

Return value

TRUE if can render, FALSE if not allowed.

1 call to _asset_page_match()
asset_textarea in ./asset.module
The #process callback function for the textareas

File

./asset.module, line 623

Code

function _asset_page_match() {
  $page_match = FALSE;
  if (!user_access('create assets') && !user_access('administer assets')) {
    return $page_match;
  }
  $access_option = variable_get('asset_access_option', 1);
  $access_pages = variable_get('asset_access_pages', "node/add/*\nnode/*/edit");
  if ($access_pages) {

    // If the PHP option wasn't selected
    if ($access_option < 2) {
      $path = drupal_get_path_alias($_GET['q']);
      $regexp = '/^(' . preg_replace(array(
        '/(\\r\\n?|\\n)/',
        '/\\\\\\*/',
        '/(^|\\|)\\\\<front\\\\>($|\\|)/',
      ), array(
        '|',
        '.*',
        '\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
      ), preg_quote($access_pages, '/')) . ')$/';
      $page_match = !($access_option xor preg_match($regexp, $path));
    }
    else {
      $page_match = drupal_eval($access_pages);
    }
  }
  elseif ($access_option == 0) {
    $page_match = TRUE;
  }
  return $page_match;
}