Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 12-22-2015, 03:37 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 87,016
Kyttias is on a distinguished road
Default Is this possible?

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:
PHP Code:
if($mysidia->input->get("id")) $user $mysidia->input->get("id"); 
I was able to take that a step further, made it this:
PHP Code:
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 Code:
$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 Code:
$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 Code:
/* title line: */
$pmForm->add(new TextField("mtitle"$title50)); 
/* 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 Code:
<a href='../../messages/newpm/{$this->fromuser}'
to
PHP Code:
<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.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 12-23-2015 at 11:00 AM.
Reply With Quote
  #2  
Old 12-22-2015, 05:42 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 327,695
Hall of Famer is on a distinguished road
Default

Well it is possible, I had the idea before that there would be a quoted text, but couldnt get the formatting done properly. Since Mysidia uses CKEditor now, there may be a solution to this, and I will see what I can do about it.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #3  
Old 12-22-2015, 07:21 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 87,016
Kyttias is on a distinguished road
Default

Thanks for helping me on aim. I editted the first post to try and explain the solution.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #4  
Old 12-22-2015, 05:04 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 327,695
Hall of Famer is on a distinguished road
Default

I see, glad you figured it out. Maybe you can post this as a mod or tutoriual, so it will be easier for other users to find. Best of luck. ^^
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #5  
Old 12-22-2015, 05:18 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 48,933
tahbikat is on a distinguished road
Default

Oohh I was actually wondering about this. Awesome, thanks for sharing Kyttias!
Reply With Quote
  #6  
Old 12-22-2015, 10:24 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 111,735
Abronsyth is on a distinguished road
Default

I did encounter an error with this when trying to send a user a PM through their profile (going to user profile and clicking "send user a PM" link), as it tries to create a PM by inserting their username into it, which I believe no longer works since this makes it so PMs are not ID'd but the username?

Not sure, super tired so I'll look into it more tomorrow but I wanted to give y'all a heads-up in case you've not tested it (though I'm aware that link may no longer exist on your site).
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #7  
Old 12-22-2015, 11:35 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 87,016
Kyttias is on a distinguished road
Default

Oh, good point Abronsyth. Links will have to be changed there, too! (Though, yeah, I've removed the link from my user's profiles, I should really add it back in...)

I think that's in classes/class_userprofile.php currently, inside the contactinfo() function. The line begins with this:
PHP Code:
 $document->add(new Link("messages/newpm/{$mysidia->input->get("user")}"
........HMMMMmmmm. Well removing the username entirely will at least remove the error, but then the newpm page won't know/remember who it should be sending something to - the entire point of having a link on the page.

Maybe... if the value is not numerical, set the recipient to whatever the value is? (edit: I've tried a lot of things, included is_numeric(), is_int(), and even going so far as !ctype_alpha() but... I seem to maybe be doing something extremely basic wrong??? I can't get this to work.)

Thoughts, HoF?
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 12-23-2015 at 12:10 AM.
Reply With Quote
  #8  
Old 12-23-2015, 01:33 AM
Distortion's Avatar
Distortion Distortion is offline
Member
 
Join Date: Dec 2015
Location: Somewhere beyond the sea
Posts: 31
Gender: Female
Credits: 3,806
Distortion is on a distinguished road
Default

replace line 178 with:
PHP Code:
 $document->add(new Link("messages/newpm/{$member->uid}""Send {$mysidia->input->get("user")} a Private Message"TRUE)); 
Basically just changing {$mysidia->input->get("user")} to {$member->uid}
__________________
Reply With Quote
  #9  
Old 12-23-2015, 01:43 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 87,016
Kyttias is on a distinguished road
Default

Well, no... the id the file is looking for is the message id of an message being sent as a reply, not a user id.

By default the url is:
.../messages/newpm
And originally the reply button linked to a page with a url like this:
.../messages/newpm/Kyttias
(A new message is created going to Kyttias, but no information about the old message itself is being sent.)

Now, we have it sending the message id number instead so we can extract the message title and text:
.../messages/newpm/25
(A reply is sent to the sender of message id #25. The message and title of message id #25 are being used to pre-fill reply information.)

The profile link still wants to create a new pm to a particular user, so it still tries to sends you here:
.../messages/newpm/Kyttias
(But this won't work with the modifications we've made, even though it's how it worked previously. If there's a 'get' value (the last end of the url) at all, it's now automatically assuming it's the message id #. The file is trying to figure out what to do with a message id #Kyttias. It's looking for a message id #, not a username, and definitely not a user id. It screams and cries and throws and error.)

I'm hoping for a way to detect whether the value is numerical only (it's definitely receiving a message id #, so go through with the new modifications) or not (it's receiving a username instead, so set the message up how it was before the mod). But everything I've tried so far has come up not working.
.
.
.

Or, and this could get messy fast, with the reply button url we could add the substring "reply_" before the message id, and on the user profile we could add the substring "user_". We could preg_match to check which substring is prefixed to the get value, and decide what to do based on if that substring exists... but then we also have to then remove that substring we attached before we can continue on. So... messy, but doable. There's got to be a better way, right?
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 12-23-2015 at 10:22 AM.
Reply With Quote
  #10  
Old 12-23-2015, 10:50 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 87,016
Kyttias is on a distinguished road
Default

Got it: It wasn't checking if it was a numeric value or not until I applied trim() to it to remove whitespace/linebreaks. I had no idea there were even there until I decided to echo the value to see what was going on.

Inside view/messagesview.php, my newpm() function now looks like this:
PHP Code:
$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(); 
Added in some optional javascript in the $js variable that should work if you have jQuery included. It'll change the title of the page to indicate it's a reply page, rather than continue to say its a new message page (assuming you're still using the h2 size for page titles, else change it).

Let me clarify that you should leave the url that sends a PM to a user alone in classes/class_userprofile.php. Keep it as it was - sending a username. Do NOT change it to send a user id.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 12-23-2015 at 11:06 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:04 AM.

Currently Active Users: 708 (0 members and 708 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636