You are here

function maxlength_nodeapi in Maxlength 5

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

File

./maxlength.module, line 187

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;
    }
  }
}