You are here

function nopremium_nodeapi in Node Option Premium 6

Implementation of hook_nodeapi().

File

./nopremium.module, line 113
Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> http://www.absyx.fr

Code

function nopremium_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'alter':
      if (!$a3 && $node->premium && !nopremium_access_full_content($node)) {
        $node = nopremium_alter_node($node, $a4);
      }
      break;
    case 'view':
      if ($a3 && $node->premium && !nopremium_access_full_content($node) && nopremium_check_content_extra_field()) {
        $node->content['nopremium_message_field'] = array(
          '#value' => theme('nopremium_message', $node, TRUE),
        );
      }
      break;
    case 'prepare':

      // Set up premium default value, if required.
      if (!isset($node->nid)) {
        $node_options = variable_get('node_options_' . $node->type, array());
        $node->premium = in_array('premium', $node_options);
      }
      break;
  }
}