You are here

function nodeblock_nodeapi in Nodeblock 6

Same name and namespace in other branches
  1. 5 nodeblock.module \nodeblock_nodeapi()

Implementation of hook_nodeapi().

File

./nodeblock.module, line 55
Enables use of specified node types as custom blocks.

Code

function nodeblock_nodeapi(&$node, $op, $teaser, $page) {

  // do nothing if not enabled
  if (!nodeblock_type_enabled($node)) {
    return;
  }
  switch ($op) {
    case 'load':
      $tnid = $node->tnid ? $node->tnid : $node->nid;
      return array(
        'nodeblock_translation_fallback' => variable_get('nodeblock_translation_fallback_' . $tnid, 1),
      );
    case 'insert':
      drupal_set_message(t('The block you just created is now available on the <a href="!url">block configuration page</a>.', array(
        '!url' => url('admin/build/block'),
      )));
    case 'update':

      // set the translation fallback variable if set.
      if (isset($node->nodeblock['translation_fallback'])) {
        $tnid = $node->tnid ? $node->tnid : $node->nid;
        variable_set('nodeblock_translation_fallback_' . $tnid, $node->nodeblock['translation_fallback']);
      }
      _block_rehash();
      break;
    case 'delete':
      _block_rehash();
      break;
  }
}