You are here

function _tinymce_page_match in TinyMCE 6

Same name and namespace in other branches
  1. 5.2 tinymce.module \_tinymce_page_match()
  2. 5 tinymce.module \_tinymce_page_match()
  3. 6.2 tinymce.module \_tinymce_page_match()

Determine if TinyMCE has permission to be used on the current page.

Return value

TRUE if can render, FALSE if not allowed.

1 call to _tinymce_page_match()
tinymce_process_textarea in ./tinymce.module
Attach tinymce to a textarea

File

./tinymce.module, line 727
Integrate the TinyMCE editor (http://tinymce.moxiecode.com/) into Drupal.

Code

function _tinymce_page_match($edit) {
  $page_match = FALSE;
  if (is_numeric(arg(1)) && arg(2) == 'edit') {
    $node = node_load(arg(1));
    $result = db_query("SELECT format FROM {filters} WHERE module = 'php'");
    while ($data = db_fetch_object($result)) {
      if ($node->format == $data->format) {
        return FALSE;
      }
    }
  }
  if ($edit->settings['access_pages']) {

    // If the PHP option wasn't selected
    if ($edit->settings['access'] < 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($edit->settings['access_pages'], '/')) . ')$/';
      $page_match = !($edit->settings['access'] xor preg_match($regexp, $path));
    }
    else {
      $page_match = drupal_eval($edit->settings['access_pages']);
    }
  }
  else {
    $page_match = TRUE;
  }
  return $page_match;
}