You are here

function ctools_access_ajax_delete in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/context-access-admin.inc \ctools_access_ajax_delete()

AJAX command to remove an access control item.

1 string reference to 'ctools_access_ajax_delete'
ctools_context_menu in includes/context.menu.inc
@file Contains menu item registration for the context tool.

File

includes/context-access-admin.inc, line 442
Contains administrative screens for the access control plugins.

Code

function ctools_access_ajax_delete($fragment = NULL, $id = NULL) {
  ctools_include('ajax');
  ctools_include('modal');
  ctools_include('context');
  if (empty($fragment) || !isset($id)) {
    ctools_ajax_render_error();
  }

  // Separate the fragment into 'module' and 'argument'
  if (strpos($fragment, '-') === FALSE) {
    $module = $fragment;
    $argument = NULL;
  }
  else {
    list($module, $argument) = explode('-', $fragment, 2);
  }
  $function = $module . '_ctools_access_get';
  if (!function_exists($function)) {
    ctools_ajax_render_error(t('Missing callback hooks.'));
  }
  list($access, $contexts) = $function($argument);
  if (isset($access['plugins'][$id])) {
    unset($access['plugins'][$id]);
  }

  // re-cache
  $function = $module . '_ctools_access_set';
  if (function_exists($function)) {
    $function($argument, $access);
  }
  $table = ctools_access_admin_render_table($access, $fragment, $contexts);
  $output = array();
  $output[] = ctools_ajax_command_replace('table#ctools-access-table', $table);
  ctools_ajax_render($output);
}