Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: GL700Wing on October 06, 2017, 01:55:28 AM

Title: Modify button for messages in topic search results
Post by: GL700Wing on October 06, 2017, 01:55:28 AM
As an Admin I sometimes need to modify multiple messages in a single topic and while I can find the relevant messages using the search function I cannot modify them directly as the only button options available in each message are Reply, Quote and Notify.

Adding the Modify button to each displayed message only requires two minor code changes:

In ./Sources/Search.php
Find:
Code: [Select]
'can_mark_notify' => in_array($message['id_board'], $boards_can['mark_any_notify']) || in_array(0, $boards_can['mark_any_notify']) && !$context['user']['is_guest'],
Add After:
Code: [Select]
// Added 'can_modify' for use in search results.
'can_modify' => (!empty($message['is_locked']) || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['id_member'] == $user_info['id'] && (empty($modSettings['edit_disable_time']) || !$message['approved'] || $message['poster_time'] + $modSettings['edit_disable_time'] * 60 > time()))),

In ./Themes/default/Search.template.php
Find:
Code: [Select]
if ($topic['can_reply'] || $topic['can_mark_notify'])
echo '
<div class="quickbuttons_wrap">
<ul class="reset smalltext quickbuttons">';


Add After:
Code: [Select]
// Added 'can_modify' to search results options.
// If they *can* modify?
if ($topic['can_modify'])
echo '
<li class="modify_button"><a href="', $scripturl, '?action=post;topic=', $topic['id'], ';msg=', $message['id'], '">', $txt['modify'], '</a></li>';