Search Sent Personal Messages (PMs)

Started by dougiefresh, July 06, 2014, 09:21:50 PM

Previous topic - Next topic

dougiefresh

Link to Mod



SEARCH SENT PERSONAL MESSAGES v2.9
By Dougiefresh -> Link to Mod



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) 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
o Perform Actions on Searched-For PMs

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.

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.

dougiefresh

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


skeletonkiss

I installed this, and for some reason, the submit button has disappeared from the search page...

dougiefresh

 :o That's not good....  I'll fix it...

dougiefresh

Uploaded v1.3 - August 24th, 2014
o Moved the submit button so that it is visible without labels being created.

dougiefresh

Uploaded v1.4 - January 19th, 2015
o License change to Simplified BSD.  No functionality change.

dougiefresh

Uploaded v1.5 - April 27th, 2015
o Updated for SMF 2.1 Beta 1

dougiefresh

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

dougiefresh

Uploaded v2.0 - March 13th, 2017[
o Rebuilt mod to work with Separate Unread PMs mod.

James Gryphon

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.

dougiefresh

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....

James Gryphon

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?

dougiefresh

#12
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....

James Gryphon

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.

dougiefresh

@James Gryphon:  I've made changes to both this mod, as well as uploaded version 1.6 of the Separate Unread PMs 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....

dougiefresh

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.




@James Gryphon:  Hopefully this update fixes the compatibility issues you reported earlier.  Thank you for the report!

GL700Wing

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' ...
Life doesn't have to be perfect to be wonderful ...

GL700Wing

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'];
Life doesn't have to be perfect to be wonderful ...

GL700Wing

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';
Life doesn't have to be perfect to be wonderful ...

dougiefresh

Uploaded v2.3 - October 9th, 2017
o Added missing string, as noted by GL700Wing in this post.




@GL700Wing:  Thank you for reporting the missing string!  I've got in this update!

Advertisement: