Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: dougiefresh on July 06, 2014, 09:21:50 PM

Title: Search Sent Personal Messages (PMs)
Post by: dougiefresh on July 06, 2014, 09:21:50 PM
Link to Mod (https://custom.simplemachines.org/mods/index.php?mod=3888)



SEARCH SENT PERSONAL MESSAGES v2.9
By Dougiefresh (http://www.simplemachines.org/community/index.php?action=profile;u=253913) -> Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3888)



Introduction
This mod allows the users of the Personal Messaging (PM) system to search sent PMs in addition to the core Inbox PMs.  With the Search Sent Personal Messages (PMs) (http://custom.simplemachines.org/mods/index.php?mod=3888) mod installed, you also get the ability to choose between read and unread outgoing PMs.

Version 2.0 introduces the concept of taking action on searched-for PMs.  (Not available on the Core theme!)

Admin Settings
There are no admin settings.  To disable it, you must remove this mod.

Related Discussions
o Search by Sent PMs (http://www.simplemachines.org/community/index.php?topic=498600)
o Perform Actions on Searched-For PMs (http://www.simplemachines.org/community/index.php?topic=521508.msg3713864#msg3713864)

Compatibility Notes
This mod was tested on SMF 2.0.15, but should work on SMF 2.1 RC2, as well as SMF 2.0 and up.  SMF 1.x is not and will not be supported.

Changelog
The changelog can be viewed at XPtsp.com (http://www.xptsp.com/board/free-modifications/search-sent-pms/?tab=1).

License
Copyright (c) 2015 - 2019, Douglas Orend
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on July 18, 2014, 03:41:51 AM
Uploaded v1.2 - July 17, 2014
o Added ability to search Sent Items by user/username
o Added ability to hide the labels when selecting Sent Items to avoid confusion

Title: Re: Search Sent Personal Messages (PMs)
Post by: skeletonkiss on August 23, 2014, 05:16:57 PM
I installed this, and for some reason, the submit button has disappeared from the search page...
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on August 24, 2014, 08:25:51 AM
 :o That's not good....  I'll fix it...
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on August 24, 2014, 08:39:39 AM
Uploaded v1.3 - August 24th, 2014
o Moved the submit button so that it is visible without labels being created.
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on January 19, 2015, 09:43:56 AM
Uploaded v1.4 - January 19th, 2015
o License change to Simplified BSD.  No functionality change.
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on April 27, 2015, 07:19:57 PM
Uploaded v1.5 - April 27th, 2015
o Updated for SMF 2.1 Beta 1
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on September 25, 2015, 10:18:47 AM
Uploaded v1.6 - August 29th, 2015
o Removed support for SMF 2.1 Beta 1
o Added support for SMF 2.1 Beta 2

Uploaded v1.7 - September 25th, 2015
o Added support for SMF 2.0.11
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on March 16, 2017, 09:50:18 PM
Uploaded v2.0 - March 13th, 2017[
o Rebuilt mod to work with Separate Unread PMs (http://custom.simplemachines.org/mods/index.php?mod=4141) mod.
Title: Re: Search Sent Personal Messages (PMs)
Post by: James Gryphon on March 28, 2017, 07:52:59 PM
Hi Doug,
I've been looking into installing some of these mods (Search Sent, Separate Unread PMs, and also Edit Unread) to replace the older Enhanced PM System mod. Unfortunately, some things haven't been going so well.

Search Sent and Separate each generate errors when attempting to install when the other one is already installed; Edit Unread also chokes when attempting to install after Search (I haven't seen whether it installs with Separate). It also gives me a "Modification parse error" when testing whether it can modify the language_english_20x.xml file.

Also, all of them pretty universally report a multitude of errors with the Core theme's template file.

Unfortunately I don't have time to go through right now and check to see what each of these errors are right now for you, but I thought I'd ask whether these errors are known and if the mods actually work fine in spite of the error reports. If you hadn't heard of any of this before and need more info, I'll provide it ASAP; I just thought I'd get this post on right now before I leave for a few hours, so you might have a chance to hear about it earlier.

I haven't done a lot of testing to see how well they work with the PM Attachments mod. I mean to look into that sometime soon, though.
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on March 28, 2017, 10:20:00 PM
Quote from: James Gryphon on March 28, 2017, 07:52:59 PM
Search Sent and Separate each generate errors when attempting to install when the other one is already installed;

Also, all of them pretty universally report a multitude of errors with the Core theme's template file.
Thank you for notifying me of these issues!  I am working to resolve these issues that you raised!  I try to make sure everything will play nice with everything else....  Guess I missed something  O:)

Quote from: James Gryphon on March 28, 2017, 07:52:59 PM
Edit Unread also chokes when attempting to install after Search (I haven't seen whether it installs with Separate). It also gives me a "Modification parse error" when testing whether it can modify the language_english_20x.xml file.

Also, all of them pretty universally report a multitude of errors with the Core theme's template file.
Fixed these issues with the Edit Unread PMs mod....
Title: Re: Search Sent Personal Messages (PMs)
Post by: James Gryphon on March 29, 2017, 03:42:26 PM
All right!

Now that my schedule is more free, do you want me to post up the error messages I get when attempting to install, or do you have that under control?
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on March 30, 2017, 09:41:16 AM
Quote from: James Gryphon on March 29, 2017, 03:42:26 PM
Now that my schedule is more free, do you want me to post up the error messages I get when attempting to install, or do you have that under control?
I'm working on it.  The only operation in conflict that I'm aware of is operation 6 in PersonalMessages.php.....  Do you have more?

EDIT:  As well as the core theme issue....
Title: Re: Search Sent Personal Messages (PMs)
Post by: James Gryphon on March 30, 2017, 06:29:41 PM
Not counting the Core theme stuff...

With "Separate Unread PMs" installed, attempting to install Search Sent PMs.

1. Replace failed (PersonalMessage.php)
Code (Find) Select
$pmbox = $context['folder'] != 'sent' ? $txt['inbox'] : $txt['sent_items'];
Code (Replace) Select
$context['folder_pmbox'] = $pmbox = ($context['folder'] != 'sent' ? ($context['folder'] != 'unread' ? $txt['inbox'] : $txt['unread_items']) : $txt['sent_items']);

With Separate Unread PMs installed, attempting to install Edit Unread PMs 1.2.

4. Add after failed (PersonalMessage.php)
Code (Find) Select
$context['folder'] = !isset($_REQUEST['f']) || $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent';
Code (Replace) Select
$context['folder'] = !isset($_GET['sa']) || $_GET['sa'] == 'edit' || $_GET['sa'] == 'edit' ? 'sent' : $context['folder'];


15. Add after failed ("Ignore errors")
16. Add before failed ("Ignore errors")

With Search Sent PMs installed, attempting to install Separate Unread PMs.

6. Replace failed (PersonalMessage.php)
Code ("Find") Select
$pmbox = $context['folder'] != 'sent' ? $txt['inbox'] : $txt['sent_items'];
Code ("Replace") Select
$pmbox = $context['folder'] == 'sent' ? $txt['sent_items'] : $context['folder'] == 'unread' ? $txt['unread_items'] : $txt['inbox'];

No apparent main errors when attempting to install Edit Unread PMs onto Search Sent PMs, except Core theme errors.

With Edit Sent PMs installed, attempting to install Separate Unread PMs.

No errors!

With Edit Sent PMs installed, attempting to install Search Sent PMs.

No main errors, except for Core theme errors.

At a quick glance, I don't think PM attachment mod impacts whether any of these mods install properly, although if someone wants to uninstall it after installing one of these mods, they need to uninstall the other mods first.
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on August 04, 2017, 02:36:25 PM
@James Gryphon:  I've made changes to both this mod, as well as uploaded version 1.6 of the Separate Unread PMs (https://custom.simplemachines.org/mods/index.php?mod=4141) mod, which contains related install-compatibility fixes.  I've going to work on the Core theme compatibility (as well as compatibility with SMF 2.1 Beta 3) before uploading the fixed version of this mod....

I haven't tested the PM Attachment mod in with this mix, though.  I can't see how it affects either of these two mods, although I really haven't dug deep into that mod, either....
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on August 04, 2017, 11:06:27 PM
Uploaded v2.1 - August 4th, 2017
o Removed support for SMF 2.1 Beta 1 & 2.
o Added support for SMF 2.1 Beta 3.
o Added almost-complete support for SMF 2.0's Core theme.
o Compatibilty changes for Separate Unread PMs (https://custom.simplemachines.org/mods/index.php?mod=4141).




@James Gryphon:  Hopefully this update fixes the compatibility issues you reported earlier.  Thank you for the report!
Title: Re: Search Sent Personal Messages (PMs)
Post by: GL700Wing on October 01, 2017, 06:56:21 AM
I've encountered a couple of 'Undefined Index' issues with v2.2 of this mod - fixes as follows:

Error Message: Undefined index: is_selected
Cause: Installation code missing.

./Sources/PersonalMessage.php
Find:
'counter' => ++$counter,

Add After:
'is_selected' => '',


Error Message: Undefined index: icon
Cause: Installation code incorrect.

./Themes/default/PersonalMessage.template.php
Find:
<td>', $message['time'], '</td>
<td>', $message['link'], '</td>
<td>', $message['member']['link'], '</td>


Replace with:
<td align="center">
<script type="text/javascript"><!-- // --><![CDATA[
currentLabels[', $message['id'], '] = {';

if (!empty($message['labels']))
{
$first = true;
foreach ($message['labels'] as $label)
{
echo $first ? '' : ',', '
"', $label['id'], '": "', $label['name'], '"';
$first = false;
}
}

echo '
};
// ]]></script>
', $message['is_replied_to'] ? '<img src="' . $settings['images_url'] . '/icons/pm_replied.gif" style="margin-right: 4px;" alt="' . $txt['pm_replied'] . '" />' : '<img src="' . $settings['images_url'] . '/icons/pm_read.gif" style="margin-right: 4px;" alt="' . $txt['pm_read'] . '" />', '</td>
<td>', $message['time'], '</td>
<td>', $message['link'], '</td>
<td>', ($context['folder'] == 'inbox' ? $message['member']['link'] : implode(', ', $message['recipients']['to'])), '</td>
<td align="center" width="4%"><input type="checkbox" name="pms[]" id="deletelisting', $message['id'], '" value="', $message['id'], '"', $message['is_selected'] ? ' checked="checked"' : '', ' onclick="if (document.getElementById(\'deletedisplay', $message['id'], '\')) document.getElementById(\'deletedisplay', $message['id'], '\').checked = this.checked;" class="input_check" /></td>


However, despite fixing these errors and installing v2.2 on an SMF 2.0.14 forum without any other mods, this mod does not return *any* results when searching 'Sent Items' ...
Title: Re: Search Sent Personal Messages (PMs)
Post by: GL700Wing on October 01, 2017, 08:43:00 AM
It took me a while to work out why the mod was still not working but I did find it and it's also due to an installation error:

Error Condition: No Messages Found
Cause: Installation code incorrect ('Add Before' used instead of 'Replace With').

./Sources/PersonalMessage.php
Find:
$context['folder'] = 'inbox';

Replace With:
$folder = (int) (isset($_REQUEST['search_what']) ? $_REQUEST['search_what'] : 1);
$context['folder'] = ($folder == 1 ? 'inbox' : (!isset($context['sup_folder']) || $folder == 2 ? 'sent' : 'unread'));



Finally, and even though I was now getting search results from 'Sent Items', the links provided did not work but after further investigation I found the cause and worked out the fix.

Error Message: You are not allowed to access this section
Cause: Installation code incorrect (the folder was always being set to 'unread' instead of using $context['folder'] when applicable).

./Sources/PersonalMessage.php
Find:
$href = $scripturl . '?action=pm;f=' . $context['folder'] . (isset($context['first_label'][$row['id_pm']]) ? ';l=' . $context['first_label'][$row['id_pm']] : '') . ';pmid=' . ($context['display_mode'] == 2 && isset($real_pm_ids[$head_pms[$row['id_pm']]]) ? $real_pm_ids[$head_pms[$row['id_pm']]] : $row['id_pm']) . '#msg' . $row['id_pm'];

Replace With:
$href = $scripturl . '?action=pm;f=' . ($context['folder'] != 'unread' && empty($context['message_read'][$row['id_pm']]) ? $context['folder'] : 'unread') . ';kstart;start=0;sort=date;pmid=' . ($context['display_mode'] == 2 && isset($real_pm_ids[$head_pms[$row['id_pm']]]) ? $real_pm_ids[$head_pms[$row['id_pm']]] : $row['id_pm']) . '#msg' . $row['id_pm'];
Title: Re: Search Sent Personal Messages (PMs)
Post by: GL700Wing on October 02, 2017, 06:06:53 AM
One last 'Undefined Index' error caused by a text string missing from a language file.

Error Message: Undefined index: sent
Cause: Missing text string

./Themes/default/languages/PersonalMessage.english.php
Find (at the end of the file):
?>

Add Before:
$txt['pm_search_what'] = 'Search group';
$txt['pm_search_to_user'] = 'To user';
$txt['sent'] = 'Sent Items';
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on October 09, 2017, 09:10:03 AM
Uploaded v2.3 - October 9th, 2017
o Added missing string, as noted by GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942) in this post (https://www.simplemachines.org/community/index.php?topic=524832.msg3943690#msg3943690).




@GL700Wing:  Thank you for reporting the missing string!  I've got in this update!
Title: Re: Search Sent Personal Messages (PMs)
Post by: GL700Wing on November 11, 2017, 12:20:05 AM
Quote from: dougiefresh on October 09, 2017, 09:10:03 AM
Uploaded v2.3 - October 9th, 2017
o Added missing string, as noted by GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942) in this post (https://www.simplemachines.org/community/index.php?topic=524832.msg3943690#msg3943690).




@GL700Wing:  Thank you for reporting the missing string!  I've got in this update!
I've just installed v2.3 but it does not contain the fixes I suggested on 1 October for the issues I found in ./Sources/PersonalMessage.php and ./Themes/default/PersonalMessage.template.php.
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on November 13, 2017, 11:22:25 AM
Uploaded v2.4 - November 13th, 2017
o Made code corrections suggested by GL700Wing (https://www.simplemachines.org/community/index.php?action=profile;u=112942) several posts back...




@GL700Wing:  Sorry!  I really don't know how I managed to miss the posts you made on October 1st.  The changes you suggested are included in this version!  Thank you!
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on November 19, 2017, 10:34:52 PM
Quote from: James Gryphon on March 28, 2017, 07:52:59 PM
Hi Doug,
I've been looking into installing some of these mods (Search Sent, Separate Unread PMs, and also Edit Unread) to replace the older Enhanced PM System mod. Unfortunately, some things haven't been going so well.

Search Sent and Separate each generate errors when attempting to install when the other one is already installed; Edit Unread also chokes when attempting to install after Search (I haven't seen whether it installs with Separate). It also gives me a "Modification parse error" when testing whether it can modify the language_english_20x.xml file.

Also, all of them pretty universally report a multitude of errors with the Core theme's template file.
Okay, I need to address the part of the "complaint" (for lack of a better phrase ATM) addressed in bold, since I haven't addressed it (yet) earlier in this thread.  All the code changes for the Core theme are present in each of the mod installers, so you don't have to tick the box to install any of these mods on the Core theme.  It'll be done automatically, since the Code theme is quite different from the Curve theme at some points.

Unfortunately, as advanced as SMF's 2.0.x's Package Manager is, it ain't perfect, in that it still misses the fact that the Core theme has it's own set of changes....  ATM, I haven't been able to test to see if the same issue exists in SMF 2.0 Beta 3...

Quote from: James Gryphon on March 28, 2017, 07:52:59 PM
I haven't done a lot of testing to see how well they work with the PM Attachments mod. I mean to look into that sometime soon, though.
I'm aware of only one incompatibility, that being with the Edit Unsent PMs mod.  PM Attachments should be installed before the Edit Unsent PMs mod.  They all should play nicely together....
Title: Re: Search Sent Personal Messages (PMs)
Post by: -Rock Lee- on November 19, 2017, 11:00:23 PM
As always here doing some spam :P ... I hope I can be active again soon translating into Spanish 8) and many things to enjoy your good works!


Regards!

PD: I leave you the normal Latin Spanish versiĆ³n and utf8 ;D
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on November 19, 2017, 11:14:16 PM
Uploaded v2.5 - November 19th, 2017
o SMF 2.0.x: Fixed installation error for PersonalMessage.template.php.
o Added Spanish Latin translation, courtsey of Rock Lee (https://www.simplemachines.org/community/index.php?action=profile;u=322597)!




@Rock Lee:  Thank you for the translation!!  It's been included in this version!
Title: Re: Search Sent Personal Messages (PMs)
Post by: Kinsman on November 25, 2017, 06:18:05 PM
Just a note that this mod is preventing a find/replace in the 2.0.1.5 update. In Sources/personalmessage.php.

Find

// Who matches those criteria?
// !!! This doesn't support sent item searching.
$request = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}members
WHERE real_name LIKE {raw:real_name_implode}',
array(
'real_name_implode' => '\'' . implode('\' OR real_name LIKE \'', $possible_users) . '\'',
)
);
// Simply do nothing if there're too many members matching the criteria.
if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch)
$userQuery = '';
elseif ($smcFunc['db_num_rows']($request) == 0)
{
$userQuery = 'AND pm.id_member_from = 0 AND (pm.from_name LIKE {raw:guest_user_name_implode})';
$searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR pm.from_name LIKE \'', $possible_users) . '\'';
}
else
{
$memberlist = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$memberlist[] = $row['id_member'];
$userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND (pm.from_name LIKE {raw:guest_user_name_implode})))';
$searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR pm.from_name LIKE \'', $possible_users) . '\'';
$searchq_parameters['member_list'] = $memberlist;
}
$smcFunc['db_free_result']($request);


Replace

if (!empty($possible_users))
{
// We need to bring this into the query and do it nice and cleanly.
$where_params = array();
$where_clause = array();
foreach ($possible_users as $k => $v)
{
$where_params['name_' . $k] = $v;
$where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}';
if (!isset($where_params['real_name']))
$where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name';
}

// Who matches those criteria?
// !!! This doesn't support sent item searching.
$request = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}members
WHERE ' . implode(' OR ', $where_clause),
$where_params
);

// Simply do nothing if there're too many members matching the criteria.
if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch)
$userQuery = '';
elseif ($smcFunc['db_num_rows']($request) == 0)
{
$where_params['real_name'] = 'pm.from_name';
$searchq_parameters = array_merge($searchq_parameters, $where_params);
$userQuery = 'AND pm.id_member_from = 0 AND (' . implode(' OR ', $where_clause) . ')';
}
else
{
$memberlist = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$memberlist[] = $row['id_member'];

$where_params['real_name'] = 'pm.from_name';
$searchq_parameters = array_merge($searchq_parameters, $where_params);
$searchq_parameters['member_list'] = $memberlist;
$userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND (' . implode(' OR ', $where_clause) . ')))';
}
$smcFunc['db_free_result']($request);
}
else
$userQuery = '';


Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on November 27, 2017, 11:25:46 AM
@Kinsman:  I know that this mod installs just fine after the SMF 2.0.15 upgrade mod.  I would suggest uninstalling this mod first (and any other conflicting mods), then installing the SMF 2.0.15 upgrade mod.  Only then should you reinstall any mods you uninstalled to get the 2.0.15 update to install....

Yup, it is a pain in the butt, but what do ya do?  :-[
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on December 08, 2017, 11:23:25 PM
@Kinsman:  Evidentally, my locahost forum was a little damaged by an incorrectly uninstalled mod.  Your bug report is reproducible on my end....  I will fix it as soon as I can....
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on December 08, 2017, 11:33:39 PM
Uploaded v2.6 - December 8th, 2017
o Added new installer to deal with SMF 2.0.15 and up.
Title: Re: Search Sent Personal Messages (PMs)
Post by: GigaWatt on May 15, 2018, 08:22:28 PM
If I right click --> open in new tab on the message, it doesn't redirect me to the message. The message URL is as follows:

http://elektronika-mk.net/index.php?action=pm;f=inbox;kstart;start=0;sort=date;pmid=38403#msg38403

I did some testing and it seems the kstart command/function is the problem. If I load the URL without it, it redirects me to the PM I've sent.

http://elektronika-mk.net/index.php?action=pm;f=inbox;start=0;sort=date;pmid=38403#msg38403

There is no entry in the error log about it.

I'm using the 2.5 version, but as I've seen the change log I don't think it matters, right ???.
Title: Re: Search Sent Personal Messages (PMs)
Post by: GigaWatt on May 15, 2018, 08:38:29 PM
Hmmmm... it seems the problem wasn't with the mod. I just deleted kstart before start=0 from the following code in PersonalMessage.php and everything is working fine.

Before:

// Parse out any BBC...
$row['body'] = parse_bbc($row['body'], true, 'pm' . $row['id_pm']);

$href = $scripturl . '?action=pm;f=' . ($context['folder'] != 'unread' && empty($context['message_read'][$row['id_pm']]) ? $context['folder'] : 'unread') . ';kstart;start=0;sort=date;pmid=' . ($context['display_mode'] == 2 && isset($real_pm_ids[$head_pms[$row['id_pm']]]) ? $real_pm_ids[$head_pms[$row['id_pm']]] : $row['id_pm']) . '#msg' . $row['id_pm'];


After:

// Parse out any BBC...
$row['body'] = parse_bbc($row['body'], true, 'pm' . $row['id_pm']);

$href = $scripturl . '?action=pm;f=' . ($context['folder'] != 'unread' && empty($context['message_read'][$row['id_pm']]) ? $context['folder'] : 'unread') . ';start=0;sort=date;pmid=' . ($context['display_mode'] == 2 && isset($real_pm_ids[$head_pms[$row['id_pm']]]) ? $real_pm_ids[$head_pms[$row['id_pm']]] : $row['id_pm']) . '#msg' . $row['id_pm'];


So what does kstart actually do?
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on May 21, 2018, 10:43:03 PM
Uploaded v2.7 - May 21st, 2018
o Fixed an issue where right click, open in new tab on the message doesn't open the PM properly.




@GigaWatt:  Thanks for the bug report, as well as the solution.  I'll be honest with ya: I'm not really sure what the kstart parameter does off the top of my head, as it's been a few years since I wrote the mod.   :P  But I've integrated your solution into the mod.  Thanks again!
Title: Re: Search Sent Personal Messages (PMs)
Post by: GigaWatt on May 22, 2018, 07:24:46 PM
Thanks for the quick update ;).

I'm glad I could help out ;).

PS: You'll have to add the new changelog to XPtsp.com :P :).

PPS: Just installed it, works like a charm ;).
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on November 01, 2018, 10:32:02 PM
Uploaded v2.8 - November 1st, 2018
o No functionality change.
o Updated documentation to point to new website.
Title: Re: Search Sent Personal Messages (PMs)
Post by: dougiefresh on June 19, 2019, 11:18:15 AM
Uploaded v2.9 - June 19th, 2019
o Added support for SMF 2.1 RC2.
o Removed support for SMF 2.1 Beta 3.
Title: Re: Search Sent Personal Messages (PMs)
Post by: Leszko on September 01, 2019, 07:56:53 AM
This mod also allows you to search in received messages, but there is one critical exception:
if you want to find any text in received messages, it is impossible when you search entering the username.
In this case you will receive fatal error message:
"The database value you're trying to insert does not exist: guest_user_name_implode"
Can it be fixed?

Analogous searching (by username) in outgoing messages works very well.



I use SMF 2.0.15 and PMs 2.7


Title: Re: Search Sent Personal Messages (PMs)
Post by: James Gryphon on July 09, 2020, 03:25:40 PM
One of the SMF updates broke a variable the mod was depending on.

Search for "guest_user_name_implode" in "PersonalMessage.php". It should be at line 1237. When you get there, change the line that it's in, the one defining $userQuery, to this:

$userQuery = $context['folder'] == 'inbox' ? 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND (' . implode(' OR ', $where_clause) . ')))'  : 'AND (pmr.id_member IN ({array_int:member_list}))';

I implemented this at a forum using the mod and it seems to fix that.
Title: Re: Search Sent Personal Messages (PMs)
Post by: James Gryphon on January 13, 2021, 12:07:31 PM
Discovered when I was attempting to fix something (the pagination seems to be broken).
PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /public_html/forum/Sources/PersonalMessage.php on line 1583
1583 is unchanged from standard SMF 2.0.17, so presumably something different from what it expects gets passed to it earlier on. I suppose I'm in a slump, because I have no idea what the problem is.

Unfortunately, this mod seems to still be the only game in town when it comes to searching the sent box, and it only marginally works. I seem to remember it being buggy even before PHP 7.2+, so I'm not sure how many of its problems are recent and how many were already there. It is important, though, especially since it looks like SMF 2.1 doesn't have this functionality and will also rely on it. If Doug isn't available and nobody volunteers to take up the mantle, the best option may be to hire someone, whether to update it with Doug's permission, or to write and release a similar one.
Title: Re: Search Sent Personal Messages (PMs)
Post by: GigaWatt on January 13, 2021, 12:19:51 PM
Quote from: James Gryphon on January 13, 2021, 12:07:31 PM
If Doug isn't available and nobody volunteers to take up the mantle, the best option may be to hire someone, whether to update it with Doug's permission, or to write and release a similar one.

According to the license, that should be permissible even without his approval ;).

It's a shame really :-\... half the mods I use are his :-\.

Oh well, I guess we'll just have to learn how to live without them :(.
Title: Re: Search Sent Personal Messages (PMs)
Post by: Kindred on January 13, 2021, 03:15:59 PM
However, providing the instructions on WHAT to update in the mod is perfectly allowed....
Title: Re: Search Sent Personal Messages (PMs)
Post by: GigaWatt on January 13, 2021, 04:20:48 PM
Quote from: Kindred on January 13, 2021, 03:15:59 PM
However, providing the instructions on WHAT to update in the mod is perfectly allowed....

Well... of course it is :D. I don't see an issue in that, some members have been doing that in support threads of abandoned mods ;).
Title: Re: Search Sent Personal Messages (PMs)
Post by: GL700Wing on January 14, 2021, 07:07:17 AM
Quote from: James Gryphon on January 13, 2021, 12:07:31 PMDiscovered when I was attempting to fix something (the pagination seems to be broken).
The pagination issue is caused by the value of the folder to search being reset to '1' (ie, inbox) when there is more than one page of results and you click on the page index link for the second or subsequent pages.

I've just worked out a fix for this using a session variable - the variable is unset when the 'Search Messages' window is displayed and it's set when the search button is clicked (at this point the folder to search has been selected).

In ./Sources/PersonalMessage.php
Find:
// !!! For the moment force the folder to the inbox.
$folder = (int) (isset($_REQUEST['search_what']) ? $_REQUEST['search_what'] : 1);
$context['folder'] = ($folder == 1 ? 'inbox' : (!isset($context['sup_folder']) || $folder == 2 ? 'sent' : 'unread'));

Replace With:
// !!! For the moment force the folder to the inbox.
if (!isset($_SESSION['pm_search_folder']))
{
$folder = (int) (isset($_REQUEST['search_what']) ? $_REQUEST['search_what'] : 1);
$context['folder'] = ($folder == 1 ? 'inbox' : (!isset($context['sup_folder']) || $folder == 2 ? 'sent' : 'unread'));
}
else
$context['folder'] = $_SESSION['pm_search_folder'];


In ./Themes/default/PersonalMessage.template.php
Find:
function template_search()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;

Add After:
// Unset the session variable for pm folder name.
unset($_SESSION['pm_search_folder']);
Title: Re: Search Sent Personal Messages (PMs)
Post by: GL700Wing on January 14, 2021, 04:18:37 PM
Quote from: GL700Wing on January 14, 2021, 07:07:17 AMThe pagination issue is caused by the value of the folder to search being reset to '1' (ie, inbox) when there is more than one page of results and you click on the page index link for the second or subsequent pages.

I've just worked out a fix for this using a session variable - the variable is unset when the 'Search Messages' window is displayed and it's set when the search button is clicked (at this point the folder to search has been selected).

And I just worked out a much simper fix which also seems to work ...

In ./Sources/PersonalMessage.php
Find:
// !!! For the moment force the folder to the inbox.
$folder = (int) (isset($_REQUEST['search_what']) ? $_REQUEST['search_what'] : 1);
$context['folder'] = ($folder == 1 ? 'inbox' : (!isset($context['sup_folder']) || $folder == 2 ? 'sent' : 'unread'));

Replace With:
if (isset($_REQUEST['search_what']))
{
$folder = (int) ($_REQUEST['search_what']);
$context['folder'] = ($folder == 1 ? 'inbox' : (!isset($context['sup_folder']) || $folder == 2 ? 'sent' : 'unread'));
};
Title: Re: Search Sent Personal Messages (PMs)
Post by: James Gryphon on January 14, 2021, 11:24:11 PM
@GL700Wing: Unfortunately I didn't have any luck with the most recent PersonalMessage.php fix, but the first and complex one seems to work fine; congrats!

I also haven't run into the count error, so I'm hoping that the problem was related to that and now the mod is in good shape.
Title: Re: Search Sent Personal Messages (PMs)
Post by: GL700Wing on January 14, 2021, 11:40:50 PM
Quote from: James Gryphon on January 14, 2021, 11:24:11 PM@GL700Wing: Unfortunately I didn't have any luck with the most recent PersonalMessage.php fix, but the first and complex one seems to work fine; congrats!

I also haven't run into the count error, so I'm hoping that the problem was related to that and now the mod is in good shape.
Glad one of them worked!