You are here

function _custom_formatters_contextual_access in Custom Formatters 7.2

Access check for contextual link in Custom formatters.

Parameters

string $name: The Custom formatter name.

array $element: The Custom formatter output render array.

Return value

bool TRUE if Contextual link is allowed to be access, else FALSE.

1 call to _custom_formatters_contextual_access()
contextual_custom_formatters_field_formatter_view_element_alter in includes/contextual.inc
Implements hook_custom_formatters_field_formatter_view_element_alter().

File

includes/contextual.inc, line 75
Contextual links module integration.

Code

function _custom_formatters_contextual_access($name, $element) {
  if (isset($element[0]['#cf_options']['#contextual_links']) && $element[0]['#cf_options']['#contextual_links'] == FALSE) {
    return FALSE;
  }
  $user_access = user_access('access contextual links') && user_access('administer custom formatters');
  if (!$user_access) {
    return FALSE;
  }
  $settings = variable_get('custom_formatters_settings', array(
    'contextual' => 1,
  ));
  $contextual = isset($settings['contextual']) ? $settings['contextual'] : 1;
  $list = array_unique(explode("\r\n", isset($settings['contextual_list']) ? $settings['contextual_list'] : ''));
  switch ($contextual) {
    case 1:
      return !in_array($name, $list) ? TRUE : FALSE;
    case 2:
      return in_array($name, $list) ? TRUE : FALSE;
  }
  return FALSE;
}