MyBB Community Forums

Full Version: Can this be turned into a plugin?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I have a modification on my forum so that the user who created a thread or post that is not yet approved can still see it.

I would like to know if there is a hook or way to turn this into a plugin so I can remove the core modifications to make it easier for when I have to update the forums.

-- WARNING: THE BELOW CHANGES ARE BASED OF MyBB 1.8.7 AND MAY REQUIRE CHANGES TO WORK WITH THE LATEST VERSION!! --

The modifications are as follow, for the showthread.php:


After

    elseif($ismod && is_moderator($fid, "canviewdeleted") == true && is_moderator($fid, "canviewunapprove") == true)
    {
        $visible = "AND p.visible IN (-1,0,1)";
    }

Add

    elseif($mybb->user['uid'] == $thread['uid'])
    {
        $visible = "AND p.visible IN (0,1)";
    }

And change:
$visibleonly = "AND visible=1";

To:

$visibleonly = "AND ((uid = " . intval($mybb->user['uid']) . " AND visible IN (0,1)) OR visible=1)";

And on the forumdisplay.php, the modifications are as follow:

Change the following lines:

$visibleonly = "AND visible='1'";
$tvisibleonly = "AND t.visible='1'";

To:

$visibleonly = 'AND ((uid = ' . intval($mybb->user['uid']) . ' AND visible IN (0,1)) OR visible = 1)';
$tvisibleonly = 'AND ((t.uid = ' . intval($mybb->user['uid']) . ' AND t.visible IN (0,1)) OR t.visible = 1)';

So again, my question is:

I would like if there is a hook or way to turn this into a plugin?

Thanks in advance for any reply.
Unfortunately there are no hooks in between the $visible declaration and the actual queries performed. You can keep track of core edits easily by using Patches though, so you just need to re-apply your changes by clicking a button every time you upgrade your board to the latest MyBB versions.
(2017-10-21, 01:39 PM)Shade Wrote: [ -> ]Unfortunately there are no hooks in between the $visible declaration and the actual queries performed. You can keep track of core edits easily by using Patches though, so you just need to re-apply your changes by clicking a button every time you upgrade your board to the latest MyBB versions.

Thanks for the reply Shade.

Yes, that is what I currently do, but last few patches broke my patch as it was unable to patch the files, it was slightly minor changes and I fixed it but its a pain honestly Toungue

Though you were talking about git patch, but it seems its a plugin to patch things, very interesting, I will check that now. Thanks.

Is there a reason why MyBB doesn't allow the own thread/post creator to view their unapproved posts/threads? I can't think of any downsides on that, on the other hand, it would help them to not have to post again or think their post did not get posted (since lots of users these days don't read much) or even get mad saying you're censoring them or w/e.
It's a legitimate question what you are asking here. I do see some advantages, but certain people might want to keep moderation actions private. It might be added as an option though. Feel free to open a new thread in the 1.8 suggestions and feedbacks forum so we can discuss this with other Team and community members.
Thanks Shade, I will do that posted it here https://community.mybb.com/thread-213698.html and thanks again for showing me that plugin trying it now and so far it looks great!