Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: GL700Wing in Oktober 06, 2017, 01:55:28 VORMITTAG

Titel: Modify button for messages in topic search results
Beitrag von: GL700Wing in Oktober 06, 2017, 01:55:28 VORMITTAG
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:
'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:
// 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:
if ($topic['can_reply'] || $topic['can_mark_notify'])
echo '
<div class="quickbuttons_wrap">
<ul class="reset smalltext quickbuttons">';



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