Hi all,

This is a great module, but there is a simple and little feature request what could be very usefull.

In the recent versions there is no solution to ignore the maxlenght module by permissions.

I did some altering:

//add the ignore permission
function maxlength_perm() {
  return array(ADMINISTER_MAXLENGTH, 'ignore maxlenght module');
}

//handle the perm in the vital parts of the module
function maxlength_form_alter(&$form, &$form_state, $form_id) {
  // Editing the content
  if(TRUE !== user_access('ignore maxlenght module')) {
    if ($form['#id'] == 'node-form') {
      _maxlength_content_form_alter($form, $form_state, $form_id);
    }
  }
...
...
...

//and at the nodeapi
function maxlength_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  $fields = array('title', 'body');

  foreach ($fields as $field) {
    $limit = intval(variable_get(MAXLENGTH_NODE_TYPE . $field .'_'. $node->type, ''));
    if(TRUE !== user_access('ignore maxlenght module')) {
      if ($limit > 0) {
        switch ($op) {
          case 'validate':
            $form = $a3;
            if (drupal_strlen($node->$field) > $limit) {
              form_set_error($field, t('The !field field has exceeded its maximum number of characters (!limit).', array('!limit' => $limit, '!field' => $field)));
            }
            break;
          }
      }
    }
  }
}

Thank you again this great module

CommentFileSizeAuthor
#5 643828.patch1.43 KBdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cleverhoods’s picture

Category: feature » bug
Status: Active » Needs work
cleverhoods’s picture

Assigned: Unassigned » cleverhoods
Category: bug » feature
a_c_m’s picture

Humm, this will only stop maxlength's length validation, many other modules will have their own which this wont override.

also i think 'bypass' is better than 'ignore'

Please submit it as a patch :) http://drupal.org/patch/create

cleverhoods’s picture

well that was the request.

bypass ONLY the maxlength validation.

dawehner’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs work » Needs review
FileSize
1.43 KB

This will certainly not be supported to 6.x, but here is a patch for 7.x

The problem with having a permission is that you can't configure&test the site as admin user,
because user_access always returns TRUE for admins. Based on this the admin will always see it.
This should probably be at least added to the readme file.

dawehner’s picture

Title: Ignore maxlenght by permission » Ignore maxlength by permission

Fix title

dawehner’s picture

Assigned: cleverhoods » dawehner

Change assigned value

cleverhoods’s picture

For normal user testings you should use the masquarade module.

vivdrupal’s picture

I have applied the patch in #5 https://drupal.org/files/issues/643828.patch
I am unable to see any change. Where should I select the roles for which the Maxlength modules is bypassed?

I need this feature asap, so please let me know.
Thanks

vivdrupal’s picture

Never mind, got the permission to show after running cron.
Also after setting the permission had to clear cache and run cron.

Thanks for the patch!

frjo’s picture

Status: Needs review » Reviewed & tested by the community

This work well in my testing and I have now deployed it in production with good results.

a_c_m’s picture

@frjo - want co-maintainership to get this code released?

frjo’s picture

@a_c_m sure, I can then commit this and #1867566: Maxlength settings added to fields where it isn't enabled that I also use in production and make a stable 7.x-3.x release.

a_c_m’s picture

Done. Over to you.

  • frjo committed 52d034d on 7.x-3.x authored by dawehner
    Issue #643828 by dawehner | lavjaman: Added Ignore maxlength by...
frjo’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.