You are here

function disable_breadcrumbs_nodeapi in Disable breadcrumbs 6

Implementation of hook_nodeapi().

File

./disable_breadcrumbs.module, line 54
Disable breadcrumbs

Code

function disable_breadcrumbs_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  $all_breadcrumbs_disabled_content_types = variable_get('disable_breadcrumbs_node_types_all', array());
  switch ($op) {
    case 'prepare':
    case 'load':

      // Cannot load if the node has not been created yet.
      if (!isset($node->nid)) {
        return;
      }
      $node->disable_breadcrumb = _disable_breadcrumbs_node_query($node->nid) ? _disable_breadcrumbs_node_query($node->nid) : 0;
      break;
    case 'alter':
      if ($node->disable_breadcrumb == 1 && !$a3 && $a4 || in_array($node->type, $all_breadcrumbs_disabled_content_types, TRUE)) {
        $breadcrumb = array();
        drupal_set_breadcrumb($breadcrumb);
      }
      break;
    case 'delete':

      //remove db record in disable_breadcrumbs table.
      $remove_query = "DELETE FROM {disable_breadcrumbs} WHERE nid = %d";
      db_query($remove_query, $node->nid);
      break;
  }
}