MyBBStuff / MyAlerts

A simple notification/alert system for MyBB similar to IPB and XenForo's core implementations of user notifications.
http://www.euantor.com/myalerts/
47 stars 33 forks source link

Alert on Replied Thread (That user can't view anymore) #41

Closed Kretol closed 11 years ago

Kretol commented 11 years ago

Is there any way to check if the user can view a thread anymore before sending an alert of a reply? I have a past moderator on my site that is still getting reply alerts for threads that he no longer has access to.

If it helps any, I recently altered the code for the old Sidebox plugin that I had installed so that it was more similar to the normal Portal page code. Specifically, I ported in this portion:

$forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);

        // Make sure we can view this thread
        if($forumpermissions[$thread['fid']]['canview'] == 0 || $forumpermissions[$thread['fid']]['canviewthreads'] == 0 || $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'])
        {
            continue;
        }

Under the while statement:

while($thread = $db->fetch_array($query))
    {

Could something like this be useful or used just to check those permissions to avoid people getting alerts for threads they can no longer view?

Thank you, and awesome work on this plugin!

euantorano commented 11 years ago

I hadn't thought of this problem! I'll patch in a fix this weekend. Thanks for alerting me! On Feb 2, 2013 6:29 AM, "Kretol" notifications@github.com wrote:

Is there any way to check if the user can view a thread anymore before sending an alert of a reply? I have a past moderator on my site that is still getting reply alerts for threads that he no longer has access to.

If it helps any, I recently altered the code for the old Sidebox plugin that I had installed so that it was more similar to the normal Portal page code. Specifically, I ported in this portion:

$forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);

    // Make sure we can view this thread
    if($forumpermissions[$thread['fid']]['canview'] == 0 || $forumpermissions[$thread['fid']]['canviewthreads'] == 0 || $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'])
    {
        continue;
    }

Under the while statement:

while($thread = $db->fetch_array($query)) {

Could something like this be useful or used just to check those permissions to avoid people getting alerts for threads they can no longer view?

Thank you, and awesome work on this plugin!

— Reply to this email directly or view it on GitHubhttps://github.com/euantor/MyAlerts/issues/41.

Sama34 commented 11 years ago

Shouldn't you build the forum permission based off all groups (primary and secondary)? From the code, I don't think this will work if the user additional group can see the thread.

Never check just for the primary usergroup! :p

Also, IMO this should be checked at the front-end (that is, when selecting the alerts to show). If the user has permission to read the thread after the alert process ended (i.e: Group Promotion just ran and promoted it). This seems to be common practice in your plugin though, so may be it is just a matter of how do you feel it should work. IMO all alerts should be inserted into the DB (checking ACP and user settings), then proper permissions checks should be done to select which threads to show in the thread.

JordanMussi commented 11 years ago

That's a good point, saving all alerts and only displaying the ones that would of nomally of been displayed. But it would mean it would take up more rows in the table and if the user can't see those alerts there is now way that they can be deleted, except from the delete old alerts feature.

euantorano commented 11 years ago

@Sama34 Oops, yes, yes I should. Darn. Wish there was an easier way to do this in the core (such a basic permissions class - then just run something like $ mybb->user->can Access('x');

And yes, it should really. I'll be changing it next release. I just wanted to get 1.04 out ASAP as I've been talking about releasing it for months now with little visible progress. I also want to get 3rd party plugins updated to the new settings system ASAP.