You are here

function data_node_active_page in Data 6

Page callback for setting the active node.

1 string reference to 'data_node_active_page'
data_node_menu in data_node/data_node.module
Implementation of hook_menu().

File

data_node/data_node.module, line 255
Hooks and API functions for Data Node module.

Code

function data_node_active_page($table, $nid) {
  data_node_set_active($table
    ->get('name'), $nid);

  // Handle AJAX requests
  if (isset($_GET['ajax'])) {

    // Generate new add/remove links to replace stale ones.
    $stale = isset($_GET['stale']) ? explode('-', $_GET['stale']) : array();
    $refresh = array();
    foreach ($stale as $id) {
      $node_list = data_node_get_nids($table, $id);
      $refresh[$id] = in_array($nid, $node_list) ? data_node_render_remove_link($table, $id, $nid) : data_node_render_add_link($table, $id, $nid);
    }
    $response = array(
      'status' => TRUE,
      'table' => $table
        ->get('name'),
      'nid' => $nid,
      'refresh' => $refresh,
    );
    drupal_json($response);
    exit;
  }
  drupal_goto($_GET['q']);
}