You are here

function radioactivity_node_nodeapi in Radioactivity 6

1 call to radioactivity_node_nodeapi()
RadioactivityNodeTestCase::testNodeApi_load in plugins/radioactivity_node.test
Tests that radioactivity_node nodeapi works as it should, i.e., when we do node load, we don't have, e.g., missing require_onces.

File

plugins/radioactivity_node.module, line 146
Node radioactivity

Code

function radioactivity_node_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'insert':
      radioactivity_add_energy($node->nid, 'node', 'node_create');
      break;
    case 'update':
      if (user_access('administer node energy')) {
        foreach ($node->radioactivity_node as $key => $value) {
          $energy = array(
            'id' => $node->nid,
            'class' => 'node',
            'decay_profile' => $key,
            'energy' => $value['energy'],
          );
          $energy = (object) $energy;
          drupal_write_record('radioactivity', $energy, 'id');
        }
      }
      break;
    case 'delete':
      radioactivity_delete_energy($node->nid, 'node');
      break;
    case 'load':
      return array(
        'radioactivity' => radioactivity_get_radioactivity_array($node->nid, 'node'),
      );
  }
}