Customizing SMF > Tips and Tricks

Modify button for messages in topic search results

(1/1)

GL700Wing:
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: --- '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'],
--- End code ---

Add After:

--- Code: --- // 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()))),
--- End code ---

In ./Themes/default/Search.template.php
Find:

--- Code: --- if ($topic['can_reply'] || $topic['can_mark_notify'])
echo '
<div class="quickbuttons_wrap">
<ul class="reset smalltext quickbuttons">';


--- End code ---

Add After:

--- Code: --- // 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>';


--- End code ---

Navigation

[0] Message Index

Go to full version