Hi

it would be great to have an option for admin to set max number of recipients. Current situation is not ideal, I have to add
'#maxlength' => 555,
into $form['privatemsg']['recipient'] , when I need to raise it.

thanks
Igor

CommentFileSizeAuthor
#15 privatemsg_1.patch1.82 KBwalker2238
#5 privatemsg.patch1.47 KBwalker2238
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

walker2238’s picture

Adding max length isn't really the way to go. Try this...

Create a module and add

// LIMIT NUMBER OF RECIPIENTS To 5
function mymodule_privatemsg_message_validate(&$message, $form = FALSE) {
    if (count($message['recipients']) > 5) {
    if ($form) {
      form_set_error('to', t('Sorry, you may only have up to 5 recipients per message.'));
    }
    else {
      $messages['error'][] = t('Sorry, you may only have up to 5 recipients per message.');
    }
  }
}
litwol’s picture

@walker2238 if its such an easy change, please submit a patch to be included in core of pmsg :).

Settings in admin section would be necessary.

walker2238’s picture

Okay, but I never did say it was easy though, or right for that matter. :) But it works for my needs.

I'll give it a go.

litwol’s picture

Sorry i didnt mean to belittle the efforts, i only wanted to say: Its a good feature, you seem to know how to do it already, lets get it in core :).

Cheers mate and thx for help.

walker2238’s picture

FileSize
1.47 KB

No worries. I've gotten a lot of support on here so it is only fair. I was just joking with you. I'm glad to help where I can. Here's a patch. Let me know if theres anything missing. Or anything that could be added.

Opps... As you can see this is my first attempt at applying a patch.

litwol’s picture

Version: » 6.x-1.x-dev

Good start.

This patch is missing one critical adition: Add a checkbox to enable/disable the max recipients feature. mac recipient should not even be checked if the feature is disabled in admin.

litwol’s picture

Status: Active » Needs work
walker2238’s picture

To be honest I don't personally like the idea of a checkbox. what if we just use 0 in the textfield to turn it of. And have that as default?

litwol’s picture

Setting max recipients to 0 to disable it would be considered to be a "magic" behavior which is a big no-no. we need things to be explicit and i think checkbox accomplishes that.

Lets brainstorm more ideas of checkbox is not good.

walker2238’s picture

Oh okay, I didn't know that.

I had it set up so that that maxlength could be up to 999... which is a lot of recipients, but not really a good way to handle things. I guess your right then. Checkbox seems the most logical unless you make a sub module.

litwol’s picture

To make sure we are on the same page: we need both check box to enable/disable the feature and a text field to specify how many recipients: 0-999 ?

walker2238’s picture

Yup,

I might end up kicking myself later but what about permissions? The main reason is for admin type users who wish to send mass PM to all site users. (Not sure if this exists for privatemsg).

litwol’s picture

That is true. However we've not figured out a way to mass message to all users or to specific groups so we should not worry about it just yet. This is a small enough patch to change later on.

So add that checkbox so others can test it :)

Berdir’s picture

Imho, that would make sense as part of the limits/quota module... #69856: Message limits. Feel free to update that and/or merge it with http://drupal.org/project/privatemsg_limits as I don't have time right now...

walker2238’s picture

Status: Needs work » Needs review
FileSize
1.82 KB

Here. I added the checkbox. I didn't test it but pretty sure it works.

I haven't looked at either of those sub modules much. Actually didn't even know privatemsg_limits existed. I'll leave it up to you guys to decide where to put it.

Berdir’s picture

Status: Needs review » Needs work

Well, I can't decide this, but imho, it does belong into either of those modules, because all other limitation settings are there too.

Your code needs work anyway, because the intendation is off.

Berdir’s picture

Status: Needs work » Closed (duplicate)

#69856: Message limits now also allows to limit the number of recipients.