You are here

function library_nodeapi in Library 6

Same name and namespace in other branches
  1. 5.2 library.module \library_nodeapi()
  2. 6.2 library.module \library_nodeapi()

Implementation of hook_nodeapi()

File

./library.module, line 796

Code

function library_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if (library_item_in_library($node)) {
    switch ($op) {
      case 'load':
        $result = array();
        $result = library_load_items($node);
        return $result;
        break;
      case 'validate':
      case 'submit':
        $node = library_validate_items($node);
        break;
      case 'insert':
      case 'update':
        library_update_items($node);
        break;
      case 'delete':
        db_query('DELETE FROM {library} WHERE nid = %d', $node->nid);
        break;
      case 'view':
        $item_weight = -4;
        if (module_exists('content')) {
          foreach (variable_get('content_extra_weights_' . $node->type, array()) as $key => $value) {
            if ($key == 'item_wrapper') {
              $item_weight = $value;
            }
          }
        }
        $node->content['items'] = array(
          '#value' => theme('library_items', $node),
          '#weight' => $item_weight,
        );
        break;
    }
  }
}