Enhanced PM System

Started by dougiefresh, April 20, 2014, 04:30:16 PM

Previous topic - Next topic

ExSpirit

Quote from: Jeff B on September 15, 2014, 02:50:12 PM
ExSpirit, can you confirm that your link ends up going to your oldest conversation?
Yes, all links lead to latest message (so anything I click latest message/conversation opens).

dougiefresh

I think I know what is going on with this mod.  I will have to rewrite that line so it only includes those parameters passed, modifying only the pm id number.  I still can't figure out why it would jump to the oldest convo, though...  it could have something to do with the parameters being passed, but I'd have to look when I get home from work....

Jeff B

dougiefresh, every time I look at your avatar, it reminds me of this commercial  :)

https://www.youtube.com/watch?v=JJkp1JXGeng

dougiefresh

#143
Quote from: Jeff B on September 17, 2014, 11:53:48 AM
dougiefresh, every time I look at your avatar, it reminds me of this commercial  :)

https://www.youtube.com/watch?v=JJkp1JXGeng
Yup....  That's how I feel, too.....  At least concerning this mod right now....

dougiefresh

#144
@ExSpirit or @Jeff B: Can one of you test something for me?  I need you to replace something and test it....

Find this:
Code (Find) Select
if ($context['display_mode'] == 2 && !empty($pmID) && in_array($pmID, $lastData['id']))
fatal_lang_error('no_access', false);

and replace it with this:
Code (Replace) Select
if ($context['display_mode'] == 2 && !empty($pmID) && !empty($lastData['id']) && $pmID != $lastData['id'])
redirectexit('action=pm;pmid=' . $lastData['id'] . (isset($_GET['kstart']) ? ';kstart' : '') . (isset($_GET['f']) ? ';f=' . $_GET['f'] : '') . (isset($_GET['start']) ? ';start=' . $_GET['start'] : '') . (isset($_GET['sort']) ? ';sort=' . $_GET['sort'] : '') . '#msg' . $lastData['id']);
elseif ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id'])
fatal_lang_error('no_access', false);

Let me know if this fixes this issue....  Thanks ahead of time!

EDIT: This is best I could come up with after a 12-hour day at work....  (keeping fingers crossed)  ::)

Jeff B

What file is this in?   I don't find it in either Sources/PersonalMessage.php  or in Themes/default/PersonalMessage.template.php

ExSpirit

There's no such code, but he probably thought this one (below this comment: "// Make sure that we have been given a correct head pm id!"):

if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id'])
redirectexit('action=pm;pmid=' . $lastData['id'] . ';kstart;f=' . $context['folder'] . ';start=0;sort=date;#msg' . $lastData['id']);


I am testing right now but it doesn't seem to be working. When I click some search result, conversation is not opened, but after a few second this is displayed in my browser: "The page isn't redirecting properly".

dougiefresh

Sorry about the late response....  Been working like crazy....

@ExSpirit or @Jeff B: Can one of you test the attached package?  You'll have to undo the changes that we talked about before upgrading to this version....

ExSpirit

#148
I can't reinstall the while thing, but I did replace sources/PersonalMessage.php (I hope that's enough, if there's something else which I should replace let me know), but when I do a search and click the link I am getting "The page isn't redirecting properly" error.

URL for the conversation which works - ?pmid=51630;kstart;f=inbox;start=20;sort=date#msg51630
URL which is shown on search result - ?f=inbox;pmid=51630#msg51630
URL which is opened after clicking search result link (and then error "The page isn't redirecting properly" is shown) - ?pmid=51588;f=inbox;start=0;sort=0#msg37508

I don't know why pmid is changed later to the wrong one... Looks like this "kstart" has something to do with the problem, because this is the thing which is present in first working link but not on search result links.

dougiefresh

Reverse both of these changes that we discussed.  To make it easier for you, I've quoted both posts.... 
Quote from: dougiefresh on September 14, 2014, 07:10:54 PM
@Jeff B: Can you edit your file to see if this fix works?  I've adjusted the code like you said....

Find this in Sources/PersonalMessage.php:
Code (Find) Select
redirectexit('action=pm;pmid=' . $lastData['id'] . ';kstart;f=' . $context['folder'] . ';start=0;sort=date;#msg' . $lastData['id']);
and replace it with this:
Code (Replace) Select
redirectexit('action=pm;f=' . $context['folder'] . ';start=0;sort=date;pmid=' . $lastData['id'] . ';#msg' . $pmID);
Quote from: dougiefresh on September 17, 2014, 06:54:16 PM
@ExSpirit or @Jeff B: Can one of you test something for me?  I need you to replace something and test it....

Find this:
Code (Find) Select
if ($context['display_mode'] == 2 && !empty($pmID) && in_array($pmID, $lastData['id']))
fatal_lang_error('no_access', false);

and replace it with this:
Code (Replace) Select
if ($context['display_mode'] == 2 && !empty($pmID) && !empty($lastData['id']) && $pmID != $lastData['id'])
redirectexit('action=pm;pmid=' . $lastData['id'] . (isset($_GET['kstart']) ? ';kstart' : '') . (isset($_GET['f']) ? ';f=' . $_GET['f'] : '') . (isset($_GET['start']) ? ';start=' . $_GET['start'] : '') . (isset($_GET['sort']) ? ';sort=' . $_GET['sort'] : '') . '#msg' . $lastData['id']);
elseif ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id'])
fatal_lang_error('no_access', false);

Let me know if this fixes this issue....  Thanks ahead of time!

EDIT: This is best I could come up with after a 12-hour day at work....  (keeping fingers crossed)  ::)

Then in PersonalMessage.php, find this:
if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id'])
redirectexit('action=pm;pmid=' . $lastData['id'] . ';kstart;f=' . $context['folder'] . ';start=0;sort=date;#msg' . $lastData['id']);

and replace it with this:
if ($context['display_mode'] == 2 && !empty($pmID) && !empty($lastData['id']) && $pmID != $lastData['id'])
redirectexit('action=pm;pmid=' . $lastData['id'] . (isset($_GET['kstart']) ? ';kstart' : '') . (isset($_GET['f']) ? ';f=' . $tmparr['f'] : '') . (isset($_GET['start']) ? ';start=' . $tmparr['start'] : '') . (isset($_GET['sort']) ? ';sort=' . $tmparr['sort'] : '') . (isset($tmparr['pmid']) ? '#msg' . $tmparr['pmid'] : ''));
elseif ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id'])
fatal_lang_error('no_access', false);


Then look for this:
// Changing view?
and add this BEFORE that comment:
// Save some variables before we start:
$tmparr = array(
'start' => isset($_GET['start']) ? $_GET['start'] : 0,
'pmid' => isset($_GET['pmid']) ? $_GET['pmid'] : 0,
'sort' => isset($_GET['sort']) ? $_GET['sort'] : 0,
'f' => isset($_GET['f']) ? $_GET['f'] : 0,
);


Let me know if this fixes the problem.  These changes are what is in the v2.4 test 1 file I updated....

ExSpirit

#150
I think I found out why I have this problem. It's because of this problem which I made:

ORDER BY ' . ($_GET['sort'] == 'pm.id_pm' && $context['folder'] != 'sent' ? 'id_pm' : '{raw:sort}') . ($descending ? ' DESC' : ' ASC') . (empty($_GET['pmsg']) ? '

I changed this to:

ORDER BY ' . ($_GET['sort'] == 'pm.id_pm' && $context['folder'] != 'sent' ? 'id_pm' : '{raw:sort}') . ($descending ? ' DESC' : ' DESC') . (empty($_GET['pmsg']) ? '

...because I want to sort messages by new to old (which works), but this causes problem with search. Do you think it would be better if I leave that as it is, but change this:

else
{
$context['sort_by'] = $_GET['sort'];
$_GET['sort'] = $sort_methods[$_GET['sort']];
$descending = isset($_GET['desc']);
}


...to this:

else
{
$context['sort_by'] = $_GET['sort'];
$_GET['sort'] = $sort_methods[$_GET['sort']];
$descending = isset($_GET['desc']);
}
$descending = "1";


And then for displayed messages (that those are sorted by oldest to newest on bottom) from this:

ORDER BY ' . ($context['display_mode'] == 2 ? 'pm.id_pm' : $_GET['sort']) . ($descending ? ' DESC' : ' ASC') . '

...to this:


ORDER BY ' . ($context['display_mode'] == 2 ? 'pm.id_pm' : $_GET['sort']) . ($descending ? ' ASC' : ' DESC') . '

Arantor

Isn't there already a preference option for 'show most recent messages on top' (in the Profile > Personal Messaging area)?

ExSpirit

It is, but that doesn't work.

Arantor

It certainly does in core SMF because I use that all the time on every SMF site I'm at.

ExSpirit

It doesn't work with this mod... That option is ignored.

dougiefresh

Quote from: Arantor on September 25, 2014, 10:35:32 AM
Isn't there already a preference option for 'show most recent messages on top' (in the Profile > Personal Messaging area)?
You are correct, there is a preference option in the core SMF software.  ExSpirit requested a separate option in order to keep the list of PM conversations sorted one way and the conversation sorted another way.

Quote from: ExSpirit on September 25, 2014, 10:53:06 AM
It is, but that doesn't work.
Untrue.  I've tested it both with and without this mod and it works just fine.  No modifications were made to the code that affect the ORDER of the PM conversations and how that switch works....

DanesDK

Hello,

I cant installe this.. Im getting alot of errors.

Does anyone know why?

Thanks

NekoJonez

Quote from: DanesDK on October 07, 2014, 03:03:25 PM
Hello,

I cant installe this.. Im getting alot of errors.

Does anyone know why?

Thanks
Do you have by any chance other mods installed?
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

DanesDK

Quote from: NekoJonez on October 07, 2014, 03:15:23 PM
Quote from: DanesDK on October 07, 2014, 03:03:25 PM
Hello,

I cant installe this.. Im getting alot of errors.

Does anyone know why?

Thanks
Do you have by any chance other mods installed?

Yes,


NekoJonez

I have a feeling that one or two of those mods added code in the files that this mod is trying to edit. Therefore not finding the exact lines and the test fails.

Maybe you should check manually?
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Advertisement: