You are here

function node_limit_nodeapi in Node Limit 6

Implementation of hook_nodeapi().

This is where we'll determine if the user may create new nodes or not. We'll key off $op == 'prepare', which is sent before the edit/add form is constructed.

File

./node_limit.module, line 94
Module to restrict the number of nodes a user or role may create.

Code

function node_limit_nodeapi($node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'prepare' || $op == 'validate') {
    if ($node->nid == 0 && _node_limit_violates_limit($node)) {

      //we have a violation!

      //and this is a new node
      $nodetypename = node_get_types('name', $node);
      drupal_set_message(t("You can't create more content of type !type", array(
        '!type' => $nodetypename,
      )), 'error');
      drupal_goto('node/add');
    }
  }
}