Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#5 | 643828.patch | 1.43 KB | dawehner |
Comments
Comment #1
cleverhoods CreditAttribution: cleverhoods commentedComment #2
cleverhoods CreditAttribution: cleverhoods commentedComment #3
a_c_m CreditAttribution: a_c_m commentedHumm, 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
Comment #4
cleverhoods CreditAttribution: cleverhoods commentedwell that was the request.
bypass ONLY the maxlength validation.
Comment #5
dawehnerThis 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.
Comment #6
dawehnerFix title
Comment #7
dawehnerChange assigned value
Comment #8
cleverhoods CreditAttribution: cleverhoods commentedFor normal user testings you should use the masquarade module.
Comment #9
vivdrupal CreditAttribution: vivdrupal commentedI 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
Comment #10
vivdrupal CreditAttribution: vivdrupal commentedNever 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!
Comment #11
frjo CreditAttribution: frjo commentedThis work well in my testing and I have now deployed it in production with good results.
Comment #12
a_c_m CreditAttribution: a_c_m commented@frjo - want co-maintainership to get this code released?
Comment #13
frjo CreditAttribution: frjo commented@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.
Comment #14
a_c_m CreditAttribution: a_c_m commentedDone. Over to you.
Comment #16
frjo CreditAttribution: frjo commented