When replying to a user's PM, I'd like to place a copy of the title and text from the original message into the new PM.
In view/messagesview.php it already detects if you're replying to a user (rather than making a new PM) by use of this:
I was able to take that a step further, made it this:
And a few lines down, I modified the where the title appears to include "RE: " before the title if new the recipient as such.
Okay, cool. That works - "RE: " only appears while I'm replying, because it knows the recipient when the page loads.
But that's also not a copy of the title I'm replying to, either, it's just a placeholder title (I added it in so people wouldn't get errors while attempting to send messages with no subject lines).
So... if $user equals a 'get' value of id, is that because that's how the url is being rewritten? Where's that the rewrite happening (because its not part of the htaccess)? If values containing the original message (and title) are already being sent, what're they called? Do I need to explicitly send these values, if they're not already being sent? (Because I don't mind jabbing at the message on the page with some javascript and attaching it to the url the reply button goes to if I have to. But do I have to?)
EDIT - Discussed this on aim with HoF. The solution was to send the message's actual id (not the username) and use the PrivateMessage object to pull data from the id that had the user name, title, and message contents.
In view/messagesview.php, inside the newpm() function, I changed the contents of the if statement mentioned above to now contain the data I asked for (EDIT 2 - this has been updated to reflect issues discussed later in the thread):
Try styling $msg up a bit, if you like, but test that it sends properly. It took me some effort to get this to look nice. I don't actually use the CKEditor so I don't know if adding in raw html will help you. (It helped me.)
Change appropriate $pmForm lines as needed. Mine's different, but this is the jist of the two lines changed:
But I need to send that data, so in classes/class_privatemessage.php, in the getMessage() function, change
to
And that'll pretty much do it. I did some other things, of course, but in case anyone's wondering for future reference.
In view/messagesview.php it already detects if you're replying to a user (rather than making a new PM) by use of this:
PHP:
if($mysidia->input->get("id")) $user = $mysidia->input->get("id");
I was able to take that a step further, made it this:
PHP:
if($mysidia->input->get("id")) {
$user = $mysidia->input->get("id");
$re = "RE: ";
}
And a few lines down, I modified the where the title appears to include "RE: " before the title if new the recipient as such.
PHP:
$pmForm->add(new TextField("mtitle", $re."(no subject)", 50));
Okay, cool. That works - "RE: " only appears while I'm replying, because it knows the recipient when the page loads.
But that's also not a copy of the title I'm replying to, either, it's just a placeholder title (I added it in so people wouldn't get errors while attempting to send messages with no subject lines).
So... if $user equals a 'get' value of id, is that because that's how the url is being rewritten? Where's that the rewrite happening (because its not part of the htaccess)? If values containing the original message (and title) are already being sent, what're they called? Do I need to explicitly send these values, if they're not already being sent? (Because I don't mind jabbing at the message on the page with some javascript and attaching it to the url the reply button goes to if I have to. But do I have to?)
EDIT - Discussed this on aim with HoF. The solution was to send the message's actual id (not the username) and use the PrivateMessage object to pull data from the id that had the user name, title, and message contents.
In view/messagesview.php, inside the newpm() function, I changed the contents of the if statement mentioned above to now contain the data I asked for (EDIT 2 - this has been updated to reflect issues discussed later in the thread):
PHP:
$message = new PrivateMessage;
// CHANGES START HERE
$title = "(no subject)"; // this way it'll never be blank
if($mysidia->input->get("id")){ // if there's an get value
$where = trim($mysidia->input->get("id")); // trim the value
if (!ctype_digit($where)) { // if its not numeric only
$user = $where; // create a message to this user
} else if (ctype_digit($where)){ // if it IS numeric only then it's a reply, so pull data
$oldMessage = new PrivateMessage($where);
$js = "<script>$('.content h2').text('Reply To Message');</script>"; // optional
$user = $oldMessage->fromuser;
$title = "RE: ".$oldMessage->messagetitle;
$msg = "› {$user} wrote: ".$oldMessage->messagetext;
}
}
// CHANGES END HERE
$editor = $message->getEditor();
Try styling $msg up a bit, if you like, but test that it sends properly. It took me some effort to get this to look nice. I don't actually use the CKEditor so I don't know if adding in raw html will help you. (It helped me.)
Change appropriate $pmForm lines as needed. Mine's different, but this is the jist of the two lines changed:
PHP:
/* title line: */
$pmForm->add(new TextField("mtitle", $title, 50));
/* editor line: */
$pmForm->add(new Comment($editor->editor("mtext", $msg)));
But I need to send that data, so in classes/class_privatemessage.php, in the getMessage() function, change
PHP:
<a href='../../messages/newpm/{$this->fromuser}'>
PHP:
<a href='../../messages/newpm/{$this->mid}'>
And that'll pretty much do it. I did some other things, of course, but in case anyone's wondering for future reference.
Last edited: