[For 1.8] [jQuery] Add Approve / Unapprove button to each post.
#1
This will add Approve / Unapprove button to each post.
This is a very basic and nominal mod for those new friends exploring MyBB. This can be further extended and enhanced as per your need.

Open template showthread_inlinemoderation, find the first line:
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/inline_moderation.js?ver=1818"></script>

ADD the following piece of script just after that:

<script type="text/javascript">
var apbt = "<a href='#' data-act='{act}' class='postbit_approve'><span>{txt}</span></a>", // Button template
    btxt = ["Approve", "Unapprove"]; // Button texts
lang.noapprove = "Deleted posts can't be approved / unapproved." // Error message for deleted posts

$(".post_management_buttons").each(function () {
    var act = $(this).parents(".post").hasClass("unapproved_post") ? 0 : 1;
    $(this).append(apbt.replace("{act}", act).replace("{txt}", btxt[act]))
}), $(function () {
    $(".postbit_approve").on("click", function () {
        return $(this).parents(".post").hasClass("deleted_post") ? $.jGrowl(lang.noapprove, {theme: "jgrowl_error"}) : ($("#" + $(this).parents(".post").attr("id").replace("post", "inlinemod")).trigger("click"), $("#inlinemoderation_options_selector").val("multi" + (+$(this).data("act") ? "un" : "") + "approveposts").change(), $("#inlinemoderation_options").trigger("submit")), !1
    })
});
</script>

Change the strings in first three lines, if you are using different language.

Note: 
  • There are several ways to do this but this script uses MyBB's inbuilt tools only.
  • This mod is just for fun and with js only. js disabled sites will not work.
  • To obtain a proper full functionality you need to have a plugin.
Reply
#2
Looks like a nice addition. You should attach a preview image Smile
Reply
#3
(2020-05-06, 11:49 PM)Omar G. Wrote: Looks like a nice addition. You should attach a preview image Smile

Sure thing ...


[Image: screen793366412e3a6466.gif]
Reply
#4
[Image: tenor.gif]
Reply
#5
I think it would be great to have a plugin that allows you to add custom moderation tools (or even stock tools) buttons to all posts or first post. I will bookmark this in case I get the chance to code such a plugin.

Meanwhile this should satisfy most needs. Very nice 👌
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)