2c2 < // $Id: quicktags.module,v 1.21.2.2 2007/02/03 11:42:00 ber Exp $ --- > // $Id: quicktags.module,v 1.2 2007/07/26 14:20:08 kartin Exp $ 37a38,74 > > $access = user_access('use PHP for block visibility'); > > // If the visibility is set to PHP mode but the user doesn't have this block permission, don't allow them to edit nor see this PHP code > if (variable_get('quicktags_access', 0) == 2 && !$access) { > $form['quicktags_options'] = array(); > $form['quicktags_options']['quicktags_access'] = array( > '#type' => 'value', > '#value' => 2 > ); > $form['quicktags_options']['quicktags_access_pages'] = array( > '#type' => 'value', > '#value' => variable_get('quicktags_access_pages', ''), > ); > } > else { > $options = array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')); > $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '!blog' for the blog page and !blog-wildcard for every personal blog. !front is the front page.", array('!blog' => theme('placeholder', 'blog'), '!blog-wildcard' => theme('placeholder', 'blog/*'), '!front' => theme('placeholder', ''))); > > if ($access) { > $options[] = t('Show if the following PHP code returns TRUE (PHP-mode, experts only).'); > $description .= t('If the PHP-mode is chosen, enter PHP code between !php. Note that executing incorrect PHP-code can break your Drupal site.', array('!php' => theme('placeholder', '<?php ?>'))); > } > $form['quicktags_options']['quicktags_access'] = array( > '#type' => 'radios', > '#title' => t('Show quicktags on specific pages'), > '#default_value' => variable_get('quicktags_access', 0), > '#options' => $options > ); > $form['quicktags_options']['quicktags_access_pages'] = array( > '#type' => 'textarea', > '#title' => t('Pages'), > '#default_value' => variable_get('quicktags_access_pages', ''), > '#description' => $description > ); > } > 90c127,128 < if (user_access('use quicktags')) { --- > $page_match = _quicktags_page_match(); > if (user_access('use quicktags') && $page_match) { 114a153,193 > * Determine if quicktags has permission to be used on the current page. > * > * @return > * TRUE if can render, FALSE if not allowed. > */ > function _quicktags_page_match() { > $page_match = FALSE; > > // Kill TinyMCE if we're editing a textarea with PHP in it! > // PHP input formats are #2 in the filters table. > if (is_numeric(arg(1)) && arg(2) == 'edit') { > $node = node_load(arg(1)); > if ($node->format == 2) { > return FALSE; > } > } > > $access = variable_get('quicktags_access', 0); > $access_pages = variable_get('quicktags_access_pages', ''); > > if ($access_pages) { > // If the PHP option wasn't selected > if ($access < 2) { > $path = drupal_get_path_alias($_GET['q']); > $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($access_pages, '/')) .')$/'; > $page_match = !($access xor preg_match($regexp, $path)); > } > else { > $page_match = drupal_eval($access_pages); > } > } > // No pages were specified to block so show on all > else { > $page_match = TRUE; > } > > return $page_match; > } > > > /**