You are here

function nodehierarchy_views_update in Node Hierarchy 7.4

Same name and namespace in other branches
  1. 5 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_update()
  2. 6.3 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_update()
  3. 6 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_update()
  4. 6.2 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_node_update in nodehierarchy_views/nodehierarchy_views.module
Implements hook_node_update().

File

nodehierarchy_views/nodehierarchy_views.module, line 201
Embed a view of children onto a node.

Code

function nodehierarchy_views_update($node) {
  if (user_access('edit embedded child view')) {
    db_delete('nodehierarchy_views')
      ->condition('nid', $node->nid)
      ->execute();
    if (!empty($node->nh_children_view)) {
      $parts = explode(':', $node->nh_children_view);
      if (!empty($parts[0])) {
        $view = $parts[0];
      }
      if (!empty($parts[1])) {
        $display = $parts[1];
      }
      else {

        // If this update is not from a form submit then the display may be stored separately.
        $display = !empty($node->nh_children_view_display) ? $node->nh_children_view_display : 'default';
      }
      $id = db_insert('nodehierarchy_views')
        ->fields(array(
        'nid' => $node->nid,
        'nh_children_view' => $view,
        'nh_children_view_display' => $display,
      ))
        ->execute();
    }
  }
}