mattbruv / Inferno-Shoutbox

A free shoutbox for MyBB forums.
MIT License
3 stars 2 forks source link

When thread notification is on, drafts trigger the notification #1

Open Kretol opened 10 years ago

Kretol commented 10 years ago

When someone saves a draft of a post, the notification for it is created in the shoutbox similar to a normal thread. The link directs to /usercp.php?action=drafts.

Kretol commented 10 years ago

Forgot to mention that I'm using MyBB 1.6.15, PHP version 5.4.26-pl0-gentoo, and MySQLi 5.5.37.

TechyZeldaNerd commented 10 years ago

Hmm, well this appears to be an issue where Mybb runs the "newthread_do_newthread_end" and the "newthread_end" hooks, even if it was only saved as a draft. I'm not really sure of a way to work around this unless we specifically check if the url is "usercp.php?action=drafts", but I'm not really an expert on Mybb.

Kretol commented 10 years ago

Ah ha! This can be fixed by ensuring the thread is visible. In function inferno_newthread(): Change

if ($settings['inferno_enabled'])
    {
        $inferno = inferno_init();
        $data = $mybb->input;
        $fid = $data['fid'];

        if ($settings['inferno_thread_post'] && !in_array($fid, explode(',', $settings['inferno_thread_forums'])))

to

if ($settings['inferno_enabled'])
    {
        $inferno = inferno_init();
        $data = $mybb->input;
        $fid = $data['fid'];
        $visible = $data['visible'];

        if ($settings['inferno_thread_post'] && $visible > 0 && !in_array($fid, explode(',', $settings['inferno_thread_forums'])))
TechyZeldaNerd commented 10 years ago

That seems to fix the issue. The only problem is that it when you finally post a draft, it doesn't appear in the SB, but that's a pretty minor thing.

Kretol commented 10 years ago

Blargh. I should have tested that more! Apparently, though it does fix drafts not showing up, it also makes it so that no thread announcements are posted! Bwa, back to the drawing board. It appears all posts will have 'visible' as 0 in the above logic whether or not they're saved as a draft or posted immediately (tried changing "> 0" to ">= 0" just to see what would happen, considering drafts as saved as a -2 in the 'visible' database column).

TechyZeldaNerd commented 10 years ago

Wait, really? Said code worked fine on my end, aside from what I mentioned before, so I'm not really sure what's going on.

Or nevermind... That's really odd though, I was certain I tested it out last night...

Kretol commented 9 years ago

Got it!

I'm still using MyBB 1.6, so it's still applicable for me (though the same fix may work for 1.8) Using the same block as before (with the addition of a change in the globals):

global $mybb, $db, $settings, $url, $lang, $tid;

if ($settings['inferno_enabled'])
    {
        $inferno = inferno_init();
        $data = $mybb->input;
        $fid = $data['fid'];
        $thread = get_thread($tid);

        if ($settings['inferno_thread_post'] && $thread['visible'] == 1 && !in_array($fid, explode(',', $settings['inferno_thread_forums'])))