You are here

function ctools_ruleset_ctools_access_merge_plugin in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 ctools_access_ruleset/plugins/access/ruleset.inc \ctools_ruleset_ctools_access_merge_plugin()

Merge the main access plugin with a loaded ruleset to form a child plugin.

2 calls to ctools_ruleset_ctools_access_merge_plugin()
ctools_ruleset_ctools_access_get_child in ctools_access_ruleset/plugins/access/ruleset.inc
Get a single child access plugin.
ctools_ruleset_ctools_access_get_children in ctools_access_ruleset/plugins/access/ruleset.inc
Get all child access plugins.

File

ctools_access_ruleset/plugins/access/ruleset.inc, line 28
Plugin to provide access control based on user rulesetission strings.

Code

function ctools_ruleset_ctools_access_merge_plugin($plugin, $parent, $item) {
  $plugin['name'] = $parent . ':' . $item->name;
  $plugin['title'] = check_plain($item->admin_title);
  $plugin['description'] = check_plain($item->admin_description);

  // TODO: Generalize this in CTools.
  if (!empty($item->requiredcontexts)) {
    $plugin['required context'] = array();
    foreach ($item->requiredcontexts as $context) {
      $info = ctools_get_context($context['name']);

      // TODO: allow an optional setting
      $plugin['required context'][] = new ctools_context_required($context['identifier'], $info['context name']);
    }
  }

  // Store the loaded ruleset in the plugin.
  $plugin['ruleset'] = $item;
  return $plugin;
}