You are here

function nodehierarchy_views_update in Node Hierarchy 5

Same name and namespace in other branches
  1. 6.3 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_update()
  2. 6 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_update()
  3. 6.2 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_update()
  4. 7.4 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_update()
  5. 7.2 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_update()

Update the given embedded view.

2 calls to nodehierarchy_views_update()
nodehierarchy_views_insert in nodehierarchy_views/nodehierarchy_views.module
Insert the given embedded view.
nodehierarchy_views_nodeapi in nodehierarchy_views/nodehierarchy_views.module
Implementation of hook_nodeapi().

File

nodehierarchy_views/nodehierarchy_views.module, line 104
Views.module integration for nodehierarchy.module.

Code

function nodehierarchy_views_update($node) {
  if (user_access('edit embedded child view')) {
    db_query('DELETE FROM {nodehierarchy_views} WHERE nid = %d', $node->nid);
    $valid_views = _nodehierarchy_views_view_options();
    if ($node->nh_children_view && isset($valid_views[$node->nh_children_view])) {
      db_query("INSERT INTO {nodehierarchy_views} (nid, nh_children_view) VALUES (%d, '%s')", $node->nid, $node->nh_children_view);
    }
    else {
      if (variable_get('nh_default_children_view_' . $node->type, NULL) !== NULL && !$node->nh_children_view) {
        db_query("INSERT INTO {nodehierarchy_views} (nid, nh_children_view) VALUES (%d, '')", $node->nid);
      }
    }
  }
}