function block_edit_visibility in Block edit 6
Calculate whether block/node edit links should be displayed.
1 call to block_edit_visibility()
- block_edit_visible in ./
block_edit.module - Calculate whether block edit links should be visible.
File
- ./
block_edit.module, line 315 - Adds edit links to blocks and nodes to make administration more intuitive.
Code
function block_edit_visibility($type) {
// If PHP is selected then evaluate it.
if (variable_get('block_edit_' . $type . '_active_type', 'disable') == 'php') {
return drupal_eval(variable_get('block_edit_' . $type . '_active_pages', ''));
}
$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(variable_get('block_edit_' . $type . '_active_pages', ''), '/')) . ')$/';
// Compare with the path alias (if one exists).
$page_match = preg_match($regexp, $path);
if ($path != $_GET['q']) {
$page_match = $page_match || preg_match($regexp, $_GET['q']);
}
// Latstly, decide whether to include or exclude pages.
if (variable_get('block_edit_' . $type . '_active_type', 'disable') == 'disable') {
return !$page_match;
}
else {
return $page_match;
}
}