You are here

function data_node_block in Data 6

Implementation of hook_block().

File

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

Code

function data_node_block($op = 'list', $delta = 0) {
  switch ($op) {
    case 'list':
      $blocks = array();
      $tables = data_get_all_tables();
      foreach ($tables as $table) {
        $meta = $table
          ->get('meta');
        if (!empty($meta['data_node']['content_type'])) {
          $blocks[$table
            ->get('name')]['info'] = t('Data node: Active node form for @table', array(
            '@table' => $table
              ->get('title'),
          ));
        }
      }
      return $blocks;
    case 'view':
      if (user_access('manage data relations') && ($table = data_get_table($delta))) {

        // Grab the node type name
        $meta = $table
          ->get('meta');
        $names = node_get_types('names');
        $type_name = check_plain($names[$meta['data_node']['content_type']]);
        return array(
          'subject' => t('Active !type', array(
            '!type' => $type_name,
          )),
          'content' => drupal_get_form('data_node_active_form', $table),
        );
      }
  }
}