You are here

function maxlength_nodeapi in Maxlength 6

Same name and namespace in other branches
  1. 5.2 maxlength.module \maxlength_nodeapi()
  2. 5 maxlength.module \maxlength_nodeapi()

Implemenation of hook_nodeapi().

File

./maxlength.module, line 202

Code

function maxlength_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  $code = MAXLENGTH_NODE_TYPE . $node->type;
  if (strlen(variable_get($code . '_b', '')) > 0) {
    switch ($op) {
      case 'validate':
        $form = $a3;
        $limit = intval(variable_get($code . '_b', ''));
        if (drupal_strlen($node->body) > $limit) {
          form_set_error('body', t('The maximum number of characters has been exceeded!'));
        }
        break;
    }
  }
}