You are here

function noderelationships_nodeapi in Node Relationships 6

Implementation of hook_nodeapi().

File

./noderelationships.module, line 330
This is the main script for the noderelationships module. It merely contains the implementation of hooks invoked by Drupal core, CCK, Views, etc. All common functions are externalized into several scripts that are included on demand.

Code

function noderelationships_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if ($op == 'view') {
    if (!$teaser && $page && $node->build_mode == NODE_BUILD_NORMAL) {

      // Include common module functions.
      module_load_include('inc', 'noderelationships');

      // Obtain back reference settings for this type.
      $backref_settings = noderelationships_settings_load($node->type, 'backref');
      $backref_regions = $backref_settings['regions'];

      // Process the node only if we have back reference settings for this region.
      if (!empty($backref_regions[NODERELATIONSHIPS_BACKREF_REGION_PAGE])) {
        module_load_include('inc', 'noderelationships', 'noderelationships.pages');
        _noderelationships_nodeapi_view($node, $backref_regions[NODERELATIONSHIPS_BACKREF_REGION_PAGE]);
      }
    }
  }
  elseif ($op == 'prepare translation') {

    // Here we can assume translation module is enabled, translation for this
    // content type is enabled and the current user is allowed to translate.
    // Include common module functions.
    module_load_include('inc', 'noderelationships');

    // Obtain settings for nodereference extras for this type.
    $noderef_settings = noderelationships_settings_load($node->type, 'noderef');

    // Proceed only if the "Translate and reference" feature is enabled for
    // any field in this content type.
    if (!empty($noderef_settings['translate_and_reference'])) {
      module_load_include('inc', 'noderelationships', 'noderelationships.translation');
      _noderelationships_nodeapi_prepare_translation($node, $noderef_settings);
    }
  }
}