News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Search Sent Personal Messages (PMs)

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

Previous topic - Next topic

GL700Wing

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 in this post.




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

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

dougiefresh

Uploaded v2.4 - November 13th, 2017
o Made code corrections suggested by GL700Wing 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!

dougiefresh

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

-Rock Lee-

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
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

dougiefresh

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!




@Rock Lee:  Thank you for the translation!!  It's been included in this version!

Kinsman

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 = '';



dougiefresh

@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?  :-[

dougiefresh

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

dougiefresh

Uploaded v2.6 - December 8th, 2017
o Added new installer to deal with SMF 2.0.15 and up.

GigaWatt

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 ???.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

GigaWatt

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?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

dougiefresh

#31
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!

GigaWatt

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 ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

dougiefresh

Uploaded v2.8 - November 1st, 2018
o No functionality change.
o Updated documentation to point to new website.

dougiefresh

Uploaded v2.9 - June 19th, 2019
o Added support for SMF 2.1 RC2.
o Removed support for SMF 2.1 Beta 3.

Leszko

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


SMF 2.0.15

James Gryphon

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

James Gryphon

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.

GigaWatt

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 :(.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Kindred

However, providing the instructions on WHAT to update in the mod is perfectly allowed....
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: