I already posted about this (
here), but almost instantly regretted doing that (I like the pattern of creating a new topic for each SMF patch, so I'm not sure why I tried to do things differently this time).
Anyway, this one came about from joker_josue pointing out that receiving PMs with no subject is annoying, and Loyce (effectively) nodding his head and saying "patch time?".
It's not something that bugs
me all that much (out of the 203 PMs I've received, 15 don't have a subject), but I can imagine it being really annoying for people with thousands of PMs in their inbox who find themselves looking back through them from time to time. Also, I've got some ideas for future patches that might allow for quickly isolating PMs by author, or subject, so phasing out (or, at least discouraging) PMs with "(No subject)" as their subject line, just seems like a good idea all-around to me.
Currently, the subject line is pre-populated with the text "(No subject)", like this:
To stop lazy MFs from just going with the default, this patch leaves the subject line empty:
If you try to send (or preview) a PM without attempting to describe what you're about to bang on about, then you'll get an error, like this:
Here's the diff for @theymos:
--- baseline/Sources/PersonalMessage.php 2011-02-07 16:45:09.000000000 +0000
+++ modified/Sources/PersonalMessage.php 2023-09-16 00:58:49.000000000 +0000
@@ -1224,33 +1224,33 @@
$request = db_query("
SELECT realName
FROM {$db_prefix}members
WHERE ID_MEMBER IN (" . implode(', ', $_REQUEST['u']) . ")
LIMIT " . count($_REQUEST['u']), __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$membersTo[] = '"' . $row['realName'] . '"';
mysql_free_result($request);
}
// Create the 'to' string - Quoting it, just in case it's something like bob,i,like,commas,man.
$_REQUEST['to'] = implode(', ', $membersTo);
}
// Set the defaults...
- $context['subject'] = $form_subject != '' ? $form_subject : $txt[24];
+ $context['subject'] = $form_subject;
$context['message'] = str_replace(array('"', '<', '>'), array('"', '<', '>'), $form_message);
$context['to'] = isset($_REQUEST['to']) ? stripslashes($_REQUEST['to']) : '';
$context['bcc'] = isset($_REQUEST['bcc']) ? stripslashes($_REQUEST['bcc']) : '';
$context['post_error'] = array();
$context['copy_to_outbox'] = !empty($options['copy_to_outbox']);
// And build the link tree.
$context['linktree'][] = array(
'url' => $scripturl . '?action=pm;sa=send',
'name' => $txt[321]
);
$context['visual_verification'] = !$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && $user_info['posts'] < $modSettings['pm_posts_verification'];
if ($context['visual_verification'])
{
$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
Edit: Adding a second diff which I think improves this patch quite a bit (read more below).
--- baseline/Themes/default/PersonalMessage.template.php 2006-12-01 15:43:03.000000000 +0000
+++ modified/Themes/default/PersonalMessage.template.php 2023-10-31 02:09:46.000000000 +0000
@@ -910,33 +910,33 @@
<td align="right"><b', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' style="color: red;"' : ''), '>', $txt[150], ':</b></td>
<td class="smalltext">
<input type="text" name="to" id="to" value="', $context['to'], '" tabindex="', $context['tabindex']++, '" size="40" />
<a href="', $scripturl, '?action=findmember;input=to;quote=1;sesc=', $context['session_id'], '" onclick="return reqWin(this.href, 350, 400);"><img src="', $settings['images_url'], '/icons/assist.gif" alt="', $txt['find_members'], '" /></a> <a href="', $scripturl, '?action=findmember;input=to;quote=1;sesc=', $context['session_id'], '" onclick="return reqWin(this.href, 350, 400);">', $txt['find_members'], '</a>
</td>
</tr><tr>
<td align="right"><b', (isset($context['post_error']['bad_bcc']) ? ' style="color: red;"' : ''), '>', $txt[1502], ':</b></td>
<td class="smalltext">
<input type="text" name="bcc" id="bcc" value="', $context['bcc'], '" tabindex="', $context['tabindex']++, '" size="40" />
<a href="', $scripturl, '?action=findmember;input=bcc;quote=1;sesc=', $context['session_id'], '" onclick="return reqWin(this.href, 350, 400);"><img src="', $settings['images_url'], '/icons/assist.gif" alt="', $txt['find_members'], '" /></a> ', $txt[748], '
</td>
</tr>';
// Subject of personal message.
echo '
<tr>
<td align="right"><b', (isset($context['post_error']['no_subject']) ? ' style="color: red;"' : ''), '>', $txt[70], ':</b></td>
- <td><input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="40" maxlength="50" /></td>
+ <td><input type="text" name="subject" placeholder="What does this message concern?" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="40" maxlength="50" /></td>
</tr>';
if ($context['visual_verification'])
{
echo '
<tr>
<td align="right" valign="top">
<b>', $txt['pm_visual_verification_label'], ':</b>
</td>
<td>';
if ($context['use_graphic_library'])
echo '
<img src="', $context['verificiation_image_href'], '" alt="', $txt['pm_visual_verification_desc'], '" /><br />';
else
echo '
<img src="', $context['verificiation_image_href'], ';letter=1" alt="', $txt['pm_visual_verification_desc'], '" />
People get attached to how things look (I know I do), and it occurred to me that three empty
<input> elements in a row might look a bit stark. I think including a
placeholder attribute on the third
<input> element will do a good job of balancing the issue this patch is meant to address (PMs without subjects) against imitating the way it looked originally (that is, two empty
<input> elements, followed by a third one with something already in it). That way, it
looks similar, but PMs will still fail to send unless you actually type something in.
Here's how it would look (I think the text I chose is short and to the point, but theymos can/should adjust it if he wants to):
Note to theymos: This new diff doesn't replace the earlier one, and they should be merged as a pair (the first diff stops the subject from being pre-populated with "(No subject)", and the second diff adds the
placeholder attribute explained above).