Private messages error

Permalink 1 user found helpful
Pretty weird problem going on with my private message system. When an admin or a user tries to send a message, the error "Woops! You've sent more mail than we can handle..." comes up, but the message sends anyway. So its working, but why the false error message? Any ideas?

coleatron
 
coleatron replied on at Permalink Reply
coleatron
Since I can't figure it out I've just edited the error message to say Thanks for sending a message.
mikezange replied on at Permalink Reply
I'm having this problem too, also I dont seem to have a reply button :S
coleatron replied on at Permalink Reply
coleatron
I don't know what to say about the no reply button. Have you tried it in a different browser? That kind of problem will likely require a complete reinstall of Concrete5.

I never did get a response about the over limit problem, instead I just modified the PHP so that the message says "Your message has been sent!"
mikezange replied on at Permalink Reply
Hey thanks for the reply, I figured out the problem with the reply button, I forgot to enable the private messages attribute for the user I was trying to reply too.

Total oversight on my part.

Im just about to change my error message to, been searching around and cant seem to find an answer. Going to asumme this is a bug.

Quick question, which file is the error message in! :P

Thanks anyway!
mikezange replied on at Permalink Reply 1 Attachment
Me again!

Figured it out

You need to enable notifications as an attribute.

I have attached an image of what I did on my site, and it works fine now, plus i get email notifications through too.

Hope this Helps!

Mike
coleatron replied on at Permalink Reply
coleatron
Thanks for the advice, but it didn't work for me. I enabled notifications as an attribute, and then enabled it on my users but I still get the modified over limit message when I send a message.
mikezange replied on at Permalink Reply 1 Attachment
Hey, hmm, dont know why it worked on mine then.

Are you sure you added the attibutes to your users properly you have to click the text of the attribute, then the little pen at the side then hit update.

I have atteched an image of my attributes page to show you what I mean.
unifiedglobal replied on at Permalink Reply
I'm no Concrete5 or PHP expert, but I can see why this would happen. There is a small bug in the userinfo.php file (/concrete/models/userinfo.php). I'll do my best to explain...

The function called sendPrivateMessage (line 246 in my userinfo.php file) should return "true" if there are no errors in sending the message. There is a condition that causes this function to return "false" (actually, no value at all) even if there were no errors. This occurs if the recipient does not have private message notifications enabled.

To correct this condition, I modified the sendPrivateMessage function as follows:

public function sendPrivateMessage($recipient, $subject, $text, $inReplyTo = false) {
    Loader::model('user_private_message');
    $subject = ($subject == '') ? t('(No Subject)') : $subject;
    $db = Loader::db();
    $dt = Loader::helper('date');
    $v = array($this->getUserID(), $dt->getLocalDateTime(), $subject, $text, $recipient->getUserID());
    $db->Execute('insert into UserPrivateMessages (uAuthorID, msgDateCreated, msgSubject, msgBody, uToID) values (?, ?, ?, ?, ?)', $v);
    $msgID = $db->Insert_ID();
    if ($msgID > 0) {
        // we add the private message to the sent box of the sender, and the inbox of the recipient
        $v = array($db->Insert_ID(), $this->getUserID(), $this->getUserID(), UserPrivateMessageMailbox::MBTYPE_SENT, 0, 1);
        $db->Execute('insert into UserPrivateMessagesTo (msgID, uID, uAuthorID, msgMailboxID, msgIsNew, msgIsUnread) values (?, ?, ?, ?, ?, ?)', $v);
        $v = array($db->Insert_ID(), $recipient->getUserID(), $this->getUserID(), UserPrivateMessageMailbox::MBTYPE_INBOX, 1, 1);
        $db->Execute('insert into UserPrivateMessagesTo (msgID, uID, uAuthorID, msgMailboxID, msgIsNew, msgIsUnread) values (?, ?, ?, ?, ?, ?)', $v);
    }


In short, I simply added an else{ return true; } to the end of the final "if" statement in the function.

You may also want to add the following to your /config/site.php file:

define('USER_PRIVATE_MESSAGE_MAX',0);
define('USER_PRIVATE_MESSAGE_MAX_TIME_SPAN',0);


This is supposed to allow you to limit the number of messages sent by a user within a given time span. You can set them to "0" if you do not wish to impose limits.
haptiK replied on at Permalink Reply
haptiK
Thank you, this proved very helpful.