Skip to content

Commit

Permalink
Merge pull request #3790 from effone/improve-modtools
Browse files Browse the repository at this point in the history
Resolves #3654 Moderation Tools Improvements
  • Loading branch information
Ben-MyBB committed Apr 17, 2024
2 parents 882af5f + 86a483c commit 526feb9
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 39 deletions.
2 changes: 0 additions & 2 deletions forumdisplay.php
Expand Up @@ -1514,8 +1514,6 @@
eval("\$addremovesubscription = \"".$templates->get("forumdisplay_threadlist_subscription")."\";");
}

$inline_edit_js = $clearstoredpass = '';

// Is this a real forum with threads?
if($foruminfo['type'] != "c")
{
Expand Down
8 changes: 4 additions & 4 deletions inc/languages/english/forumdisplay.lang.php
Expand Up @@ -95,8 +95,8 @@
$l['select_all'] = "Select all <strong>{1}</strong> threads in this forum.";
$l['clear_selection'] = "Clear Selection.";
$l['deleted_thread'] = "Deleted Thread";

$l['select_a_tool'] = "Select A Tool";
$l['error_containsnoforums'] = "Sorry, but the forum you are currently viewing does not contain any child forums.";

$l['inline_edit_description'] = '(Click and hold to edit)';

$l['inline_no_tool_selected'] = "Please select a tool to perform moderation action.";
$l['inline_no_post_selected'] = "You need to select one or more posts to perform the moderation action on.";
$l['inline_edit_description'] = '(Click and hold to edit)';
2 changes: 1 addition & 1 deletion inc/languages/english/moderation.lang.php
Expand Up @@ -159,7 +159,7 @@
$l['purgespammer_modlog'] = "Purged Spammer";

$l['error_invalidpm'] = "Invalid PM";
$l['error_nomergeposts'] = "You need to select one or more posts to be able to merge posts together.";
$l['error_nomergeposts'] = "You need to select at least two or more posts to be able to merge posts together.";
$l['error_cantsplitonepost'] = "You cannot split a thread that contains only one post.";
$l['error_badmergeurl'] = "The URL for the thread to be merged seems to be invalid or empty. Please copy the exact URL into the textbox.<br />Please go back and try again.";
$l['error_badmovepostsurl'] = "The URL for the thread to move to seems to be invalid or empty. Please copy the exact URL into the textbox.<br />Please go back and try again.";
Expand Down
7 changes: 5 additions & 2 deletions inc/languages/english/showthread.lang.php
Expand Up @@ -6,8 +6,10 @@
*/

$l['delete_poll'] = "Delete Poll";
$l['open_thread'] = "Open Thread";
$l['close_thread'] = "Close Thread";
$l['stick_thread'] = "Stick Thread";
$l['unstick_thread'] = "Unstick Thread";

$l['author'] = "Author";
$l['message'] = "Message";
Expand All @@ -21,17 +23,16 @@
$l['unsubscribe_thread'] = "Unsubscribe from this thread";
$l['add_poll_to_thread'] = "Add Poll to this thread";
$l['moderation_options'] = "Moderation Options:";
$l['select_a_tool'] = "Select A Tool";
$l['delayed_moderation'] = "Delayed Moderation";
$l['thread_notes'] = "Edit / View Thread Notes";
$l['open_close_thread'] = "Open / Close Thread";
$l['approve_thread'] = "Approve Thread";
$l['unapprove_thread'] = "Unapprove Thread";
$l['soft_delete_thread'] = "Soft Delete Thread";
$l['restore_thread'] = "Restore Thread";
$l['delete_thread'] = "Delete Thread Permanently";
$l['delete_posts'] = "Delete Selective Posts";
$l['move_thread'] = "Move / Copy Thread";
$l['stick_unstick_thread'] = "Stick / Unstick Thread";
$l['split_thread'] = "Split Thread";
$l['merge_threads'] = "Merge Threads";
$l['remove_redirects'] = "Remove Redirects";
Expand Down Expand Up @@ -82,6 +83,8 @@
$l['inline_approve_posts'] = "Approve Posts";
$l['inline_unapprove_posts'] = "Unapprove Posts";
$l['inline_post_moderation'] = "Inline Post Moderation:";
$l['inline_no_tool_selected'] = "Please select a tool to perform moderation action.";
$l['inline_no_post_selected'] = "You need to select one or more posts to perform the moderation action on.";
$l['inline_go'] = "Go";
$l['clear'] = "Clear";
$l['thread_closed'] = "Thread Closed";
Expand Down
48 changes: 23 additions & 25 deletions install/resources/mybb_theme.xml
Expand Up @@ -3863,13 +3863,14 @@ var announcement_quickdelete_confirm = "{$lang->announcement_quickdelete_confirm
</td>
</tr>]]></template>
<template name="forumdisplay_announcements_announcement_modbit" version="1800"><![CDATA[<td align="center" class="{$bgcolor} forumdisplay_announcement">-</td>]]></template>
<template name="forumdisplay_inlinemoderation" version="1821"><![CDATA[<script type="text/javascript" src="{$mybb->asset_url}/jscripts/inline_moderation.js?ver=1821"></script>
<form action="moderation.php" method="post">
<template name="forumdisplay_inlinemoderation" version="1838"><![CDATA[<script type="text/javascript" src="{$mybb->asset_url}/jscripts/inline_moderation.js?ver=1838"></script>
<form id="inlinemoderation_options" action="moderation.php" method="post">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="fid" value="{$fid}" />
<input type="hidden" name="modtype" value="inlinethread" />
<span class="smalltext"><strong>{$lang->inline_thread_moderation}</strong></span>
<select name="action">
<select name="action" id="inlinemoderation_options_selector">
<option value="" style="display: none;" selected="selected">{$lang->select_a_tool}</option>
<option value="delayedmoderation">{$lang->delayed_moderation}</option>
{$standardthreadtools}
{$customthreadtools}
Expand All @@ -3883,6 +3884,8 @@ var announcement_quickdelete_confirm = "{$lang->announcement_quickdelete_confirm
var all_text = "{$threadcount}";
var inlineType = "forum";
var inlineId = {$fid};
lang.select_tool = "{$lang->inline_no_tool_selected}";
lang.selected_nil = "{$lang->inline_no_post_selected}";
// -->
</script>
<br />]]></template>
Expand Down Expand Up @@ -4046,7 +4049,8 @@ var announcement_quickdelete_confirm = "{$lang->announcement_quickdelete_confirm
</td>]]></template>
<template name="forumdisplay_thread_rating_moved" version="1800"><![CDATA[<td class="{$bgcolor}" style="text-align: center;">-</td>]]></template>
<template name="forumdisplay_thread_unapproved_posts" version="1800"><![CDATA[ <span title="{$unapproved_posts_count}">({$thread['unapprovedposts']})</span>]]></template>
<template name="forumdisplay_threadlist" version="1827"><![CDATA[<div class="float_left">

<template name="forumdisplay_threadlist" version="1838"><![CDATA[<div class="float_left">
{$multipage}
</div>
<div class="float_right">
Expand Down Expand Up @@ -4106,8 +4110,7 @@ var announcement_quickdelete_confirm = "{$lang->announcement_quickdelete_confirm
{$searchforum}
{$forumjump}
</div>
<br class="clear" />
{$inline_edit_js}]]></template>
<br class="clear" />]]></template>
<template name="forumdisplay_threadlist_clearpass" version="1606"><![CDATA[ | <a href="misc.php?action=clearpass&amp;fid={$fid}&amp;my_post_key={$mybb->post_code}">{$lang->clear_stored_password}</a>]]></template>
<template name="forumdisplay_threadlist_prefixes" version="1801"><![CDATA[<select name="prefix">
<option value="-2"{$default_selected['any']}>{$lang->prefix_any}</option>
Expand Down Expand Up @@ -11275,7 +11278,7 @@ if(use_xmlhttprequest == "1")
</html>]]></template>
<template name="search_results_posts_forumlink" version="1808"><![CDATA[<a href="{$post['forumlink_link']}">{$post['forumlink_name']}</a>]]></template>
<template name="search_results_posts_inlinecheck" version="120"><![CDATA[<td class="{$bgcolor}" align="center" style="white-space: nowrap"><input type="checkbox" class="checkbox" name="inlinemod_{$post['pid']}" id="inlinemod_{$post['pid']}" value="1" style="vertical-align: middle;" {$inlinecheck} /></td>]]></template>
<template name="search_results_posts_inlinemoderation" version="1821"><![CDATA[<script type="text/javascript" src="{$mybb->asset_url}/jscripts/inline_moderation.js?ver=1821"></script>
<template name="search_results_posts_inlinemoderation" version="1838"><![CDATA[<script type="text/javascript" src="{$mybb->asset_url}/jscripts/inline_moderation.js?ver=1838"></script>
<form action="moderation.php" method="post" style="margin-top: 0; margin-bottom: 0;">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="tid" value="0" />
Expand Down Expand Up @@ -11369,7 +11372,7 @@ if(use_xmlhttprequest == "1")
</html>]]></template>
<template name="search_results_threads_forumlink" version="1808"><![CDATA[<a href="{$thread['forumlink_link']}">{$thread['forumlink_name']}</a>]]></template>
<template name="search_results_threads_inlinecheck" version="120"><![CDATA[<td class="{$bgcolor}" align="center" style="white-space: nowrap"><input type="checkbox" class="checkbox" name="inlinemod_{$thread['tid']}" id="inlinemod_{$thread['tid']}" value="1" style="vertical-align: middle;" {$inlinecheck} /></td>]]></template>
<template name="search_results_threads_inlinemoderation" version="1821"><![CDATA[<script type="text/javascript" src="{$mybb->asset_url}/jscripts/inline_moderation.js?ver=1821"></script>
<template name="search_results_threads_inlinemoderation" version="1838"><![CDATA[<script type="text/javascript" src="{$mybb->asset_url}/jscripts/inline_moderation.js?ver=1838"></script>
<form action="moderation.php" method="post">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="fid" value="0" />
Expand Down Expand Up @@ -11487,7 +11490,7 @@ if(use_xmlhttprequest == "1")
<td width="5%" class="{$bgcolor}"><div class="postbit_buttons">{$emailcode}</div></td>
<td width="5%" class="{$bgcolor}"><div class="postbit_buttons">{$pmcode}</div></td>
</tr>]]></template>
<template name="showthread" version="1827"><![CDATA[<html>
<template name="showthread" version="1838"><![CDATA[<html>
<head>
<title>{$thread['subject']}</title>
{$headerinclude}
Expand All @@ -11496,6 +11499,8 @@ if(use_xmlhttprequest == "1")
var quickdelete_confirm = "{$lang->quickdelete_confirm}";
var quickrestore_confirm = "{$lang->quickrestore_confirm}";
var allowEditReason = "{$mybb->settings['alloweditreason']}";
var thread_deleted = "{$thread_deleted}";
var visible_replies = "{$thread['replies']}";
lang.save_changes = "{$lang->save_changes}";
lang.cancel_edit = "{$lang->cancel_edit}";
lang.quick_edit_update_error = "{$lang->quick_edit_update_error}";
Expand All @@ -11514,7 +11519,7 @@ if(use_xmlhttprequest == "1")
<!-- jeditable (jquery) -->
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/report.js?ver=1820"></script>
<script src="{$mybb->asset_url}/jscripts/jeditable/jeditable.min.js"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/thread.js?ver=1827"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/thread.js?ver=1838"></script>
</head>
<body>
{$header}
Expand Down Expand Up @@ -11595,13 +11600,14 @@ if(use_xmlhttprequest == "1")
<td class="tcat"><span class="smalltext"><strong>{$lang->message}</strong></span></td>
</tr>
]]></template>
<template name="showthread_inlinemoderation" version="1821"><![CDATA[<script type="text/javascript" src="{$mybb->asset_url}/jscripts/inline_moderation.js?ver=1821"></script>
<template name="showthread_inlinemoderation" version="1838"><![CDATA[<script type="text/javascript" src="{$mybb->asset_url}/jscripts/inline_moderation.js?ver=1838"></script>
<form action="moderation.php" method="post" style="margin-top: 0; margin-bottom: 0;" id="inlinemoderation_options">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="tid" value="{$tid}" />
<input type="hidden" name="modtype" value="inlinepost" />
<span class="smalltext"><strong>{$lang->inline_post_moderation}</strong></span>
<select name="action" id="inlinemoderation_options_selector">
<option value="" style="display: none;" selected="selected">{$lang->select_a_tool}</option>
{$standardposttools}
{$customposttools}
</select>
Expand All @@ -11614,10 +11620,8 @@ if(use_xmlhttprequest == "1")
var all_text = "{$threadcount}";
var inlineType = "thread";
var inlineId = {$tid};

$("#inlinemoderation_options_selector").on('change', function() {
$("#inlinemoderation_options").trigger('submit');
})
lang.select_tool = "{$lang->inline_no_tool_selected}";
lang.selected_nil = "{$lang->inline_no_post_selected}";
// -->
</script><br />]]></template>
<template name="showthread_inlinemoderation_approve" version="1800"><![CDATA[<option value="multiapproveposts">{$lang->inline_approve_posts}</option>
Expand All @@ -11637,28 +11641,22 @@ if(use_xmlhttprequest == "1")
{$inlinemodapprove}
</optgroup>]]></template>
<template name="showthread_inlinemoderation_softdelete" version="1800"><![CDATA[<option value="multisoftdeleteposts">{$lang->inline_soft_delete_posts}</option>]]></template>
<template name="showthread_moderationoptions" version="1800"><![CDATA[{$inlinemod}
<template name="showthread_moderationoptions" version="1838"><![CDATA[{$inlinemod}
<form action="moderation.php" method="post" style="margin-top: 0; margin-bottom: 0;" id="moderator_options">
<input type="hidden" name="modtype" value="thread" />
<input type="hidden" name="tid" value="{$tid}" />
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<span class="smalltext">
<strong>{$lang->moderation_options}</strong></span>
<select name="action" id="moderator_options_selector">
<option value="" style="display: none;" selected="selected">{$lang->select_a_tool}</option>
<option value="delayedmoderation">{$lang->delayed_moderation}</option>
{$standardthreadtools}
{$customthreadtools}
</select>
{$gobutton}
</form>
<br />
<script type="text/javascript">
<!--
$("#moderator_options_selector").on('change', function() {
$("#moderator_options").trigger('submit');
})
//-->
</script>]]></template>
<br />]]></template>
<template name="showthread_moderationoptions_approve" version="1818"><![CDATA[<option class="option_mirage" value="approvethread">{$lang->approve_thread}</option>]]></template>
<template name="showthread_moderationoptions_custom" version="120"><![CDATA[<optgroup label="{$lang->custom_mod_tools}">{$customthreadtools}</optgroup>]]></template>
<template name="showthread_moderationoptions_custom_tool" version="1818"><![CDATA[<option class="option_mirage" value="{$tool['tid']}">{$tool['name']}</option>]]></template>
Expand All @@ -11683,7 +11681,7 @@ if(use_xmlhttprequest == "1")
{$approveunapprovethread}
</optgroup>]]></template>
<template name="showthread_moderationoptions_stickunstick" version="1818"><![CDATA[<option class="option_mirage" value="stick">{$lang->stick_unstick_thread}</option>]]></template>
<template name="showthread_moderationoptions_threadnotes" version="1800"><![CDATA[<option value="threadnotes" selected="selected">{$lang->thread_notes}</option>]]></template>
<template name="showthread_moderationoptions_threadnotes" version="1838"><![CDATA[<option value="threadnotes">{$lang->thread_notes}</option>]]></template>
<template name="showthread_moderationoptions_unapprove" version="1818"><![CDATA[<option class="option_mirage" value="unapprovethread">{$lang->unapprove_thread}</option>]]></template>
<template name="showthread_newreply" version="1800"><![CDATA[<a href="newreply.php?tid={$tid}" class="button new_reply_button"><span>{$lang->new_reply}</span></a>&nbsp;]]></template>
<template name="showthread_newreply_closed" version="1800"><![CDATA[<a href="newreply.php?tid={$tid}" class="button closed_button"><span>{$lang->thread_closed}</span></a>&nbsp;]]></template>
Expand Down
18 changes: 18 additions & 0 deletions jscripts/inline_moderation.js
@@ -1,6 +1,24 @@
var inlineModeration = {
init: function()
{
$(function(){
if($("#inlinemoderation_options_selector").length !== 0) {
$("#inlinemoderation_options_selector").on('change', function() {
$("#inlinemoderation_options").trigger('submit');
});

$("#inlinemoderation_options").on('submit', function(){
if($("#inlinemoderation_options_selector").val() == "") {
$.jGrowl(lang.select_tool, {theme:'jgrowl_error'});
return false;
} else if($('input[name^="inlinemod_"]:checked').length === 0) {
$.jGrowl(lang.selected_nil, {theme:'jgrowl_error'});
return false;
}
});
}
});

if(!inlineType || !inlineId)
{
return false;
Expand Down
45 changes: 43 additions & 2 deletions jscripts/thread.js
Expand Up @@ -6,6 +6,28 @@ var Thread = {
Thread.initQuickReply();
Thread.initMultiQuote();

if(thread_deleted == "1")
{
$("#quick_reply_form, .new_reply_button, .thread_tools, .inline_rating").hide();
$("#moderator_options_selector option.option_mirage").attr("disabled","disabled");
}

visible_replies = parseInt(visible_replies, 10);
Thread.splitToolHandler();

if($("#moderator_options_selector").length !== 0) {
$("#moderator_options_selector").on('change', function() {
$("#moderator_options").trigger('submit');
});

$("#moderator_options").on('submit', function(){
if($("#moderator_options_selector").val() == "") {
$.jGrowl(lang.select_tool, {theme:'jgrowl_error'});
return false;
}
});
}

// Set spinner image
$('#quickreply_spinner img').attr('src', spinner_image);
});
Expand Down Expand Up @@ -411,6 +433,9 @@ var Thread = {

$('#posts').append(json.data);

++visible_replies;
Thread.splitToolHandler();

if (typeof inlineModeration != "undefined") // Guests don't have this object defined
$("#inlinemod_" + pid).on('change', inlineModeration.checkItem);

Expand Down Expand Up @@ -488,17 +513,20 @@ var Thread = {
$("#quick_reply_form, .thread_tools, .new_reply_button, .inline_rating").hide();
$("#moderator_options_selector option.option_mirage").attr("disabled","disabled");
$("#moderator_options_selector option[value='softdeletethread']").val("restorethread").text(lang.restore_thread);
thread_deleted = "1";
}

$.jGrowl(lang.quick_delete_success, {theme:'jgrowl_success'});
}
else if(json.data == 2)
{
// Actually deleted
$('#post_'+pid).slideToggle("slow");

--visible_replies;
Thread.splitToolHandler();
$.jGrowl(lang.quick_delete_success, {theme:'jgrowl_success'});
} else if(json.data == 3)
}
else if(json.data == 3)
{
// deleted thread --> redirect

Expand Down Expand Up @@ -564,6 +592,7 @@ var Thread = {
$("#quick_reply_form, .thread_tools, .new_reply_button, .inline_rating").show();
$("#moderator_options_selector option.option_mirage").prop("disabled", false);
$("#moderator_options_selector option[value='restorethread']").val("softdeletethread").text(lang.softdelete_thread);
thread_deleted = "";
}

$.jGrowl(lang.quick_restore_success, {theme:'jgrowl_success'});
Expand All @@ -584,6 +613,18 @@ var Thread = {
viewNotes: function(tid)
{
MyBB.popupWindow("/moderation.php?action=viewthreadnotes&tid="+tid+"&modal=1");
},

splitToolHandler: function()
{
if($(thread_deleted !== "1" && "#moderator_options_selector").length !== 0){
var splitTool = $("#moderator_options_selector").find("option[value=split]");
if(visible_replies > 0) {
splitTool.prop("disabled", false);
} else {
splitTool.attr("disabled","disabled");
}
}
}
};

Expand Down
10 changes: 7 additions & 3 deletions moderation.php
Expand Up @@ -2321,9 +2321,13 @@
}
}

if(empty($posts))
if(count($posts) < 2)
{
error($lang->error_inline_nopostsselected, $lang->error);
if(empty($posts))
{
error($lang->error_inline_nopostsselected, $lang->error);
}
error($lang->error_nomergeposts, $lang->error);
}

if(!is_moderator_by_pids($posts, "canmanagethreads"))
Expand Down Expand Up @@ -2385,7 +2389,7 @@
verify_post_check($mybb->get_input('my_post_key'));

$mergepost = $mybb->get_input('mergepost', MyBB::INPUT_ARRAY);
if(count($mergepost) <= 1)
if(count($mergepost) < 2)
{
error($lang->error_nomergeposts, $lang->error);
}
Expand Down
16 changes: 16 additions & 0 deletions showthread.php
Expand Up @@ -1438,11 +1438,27 @@

if(is_moderator($forum['fid'], "canopenclosethreads"))
{
if($thread['closed'])
{
$lang->open_close_thread = $lang->open_thread;
}
else
{
$lang->open_close_thread = $lang->close_thread;
}
eval("\$openclosethread = \"".$templates->get("showthread_moderationoptions_openclose")."\";");
}

if(is_moderator($forum['fid'], "canstickunstickthreads"))
{
if($thread['sticky'])
{
$lang->stick_unstick_thread = $lang->unstick_thread;
}
else
{
$lang->stick_unstick_thread = $lang->stick_thread;
}
eval("\$stickunstickthread = \"".$templates->get("showthread_moderationoptions_stickunstick")."\";");
}

Expand Down

0 comments on commit 526feb9

Please sign in to comment.