You are here

function ccl_actions_ccl_cache_update in Custom Contextual Links 7

Same name and namespace in other branches
  1. 8 ccl_actions/ccl_actions.module \ccl_actions_ccl_cache_update()

Hook function triggered by the chache update routine of the main module.

File

ccl_actions/ccl_actions.module, line 369
Implementation of core actions for CCL.

Code

function ccl_actions_ccl_cache_update() {
  $actions = db_query("SELECT * FROM {ccl} WHERE type = :type", array(
    ':type' => 'action',
  ));
  $actions_cache = array(
    'global' => array(),
    'ct' => array(),
    'ids' => array(),
  );
  foreach ($actions as $action) {
    $action->options = unserialize($action->options);
    $filtered_actions = array_keys(array_filter($action->options['actions_select']));
    if ($action->options['node_options'] == 'global') {
      $actions_cache['global'][] = $filtered_actions;
    }
    elseif ($action->options['node_options'] == 'node') {
      $actions_cache['ids'][$action->options['node_id']][] = $filtered_actions;
    }
    else {
      $actions_cache['ct'][$action->options['node_type']][] = $filtered_actions;
    }
  }
  cache_set('ccl_actions', $actions_cache);
}