Wedge

Public area => The Pub => Plugins => Topic started by: live627 on June 21st, 2012, 02:41 AM

Title: Extending the moderation filter actions when posting
Post by: live627 on June 21st, 2012, 02:41 AM
Currently, only the known variables can be extended through a hook. It should follow, then, that the actual filtering should also be plugin-friendly.

Now, the problem is how exactly to extend these best. Currently, each action is handled in a big switch syntax. I see two ways to do this. We could run with this (using the "default" case) or divide each action into separate functions.

Thoughts?
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on June 21st, 2012, 03:18 PM
It isn't handled in a big switch case.

There's two parts to extending moderation filters.

Firstly, there's defining more types of rules, for example you could use that to declare a rule based on the number of likes a person has (since that's not currently in the system), you'd call moderation_rules to actually set up the actual processing of that rule. (You'd declare both its definition and if inside the admin panel, also go on to load the templates and language strings for it) - this is where the big switch comes in, but it's already extensible.

Secondly, there's the actual process of applying rules. This is currently not extensible in any fashion, but what would you want to do with a post in a moderation context, that isn't preventing/moderation/pin/unpin/lock/unlock, exactly?

If you did, for some random reason, want to set something up, add a new hook call in just before    // Any mistakes? in Post2.php.
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on September 27th, 2012, 02:35 AM
Random question: would it be useful to extend Topic Solved with this to prove it all works?
Title: Re: Extending the moderation filter actions when posting
Post by: live627 on September 27th, 2012, 09:23 AM
/solved = solve this topic? It would be a good way to test the mod filters and I like that idea.
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on September 27th, 2012, 12:09 PM
Well, that's the beauty of it, you can configure it in all sorts of fun ways - /solved is the canonical example but not required to be that.
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on December 9th, 2012, 11:54 PM
I never did get around to this one. I need to investigate this particular case since it's an entire class of action not currently possible.
Title: Re: Extending the moderation filter actions when posting
Post by: Nao on December 15th, 2012, 08:36 PM
Okay, I don't know where to post about this, and given that my network issues took away most of my mana for the day, I'm not going to bother fighting too hard against my internal compass... :P

About the moderation filters.
- How exactly can I trigger that popup...?[1] I really need to see what I'm trying to translate, because it has a strange ring to it... (?)
- Create a new filter, with Chrome for instance. First dropdown choice. Then first DD choice. Then choose 'Depends on post subject'. Click inside the text input and type anything. My problem comes from the fact that it only shows the Add button once you focus out of the box. It should be triggered when you start typing something, or even right after you select the filter type (e.g. 'Depends on post subject'.)
- Also, the 'Informing the user' part shows up after you select the second dropdown. It should either show up before the condition list, or be shown only when the 'Save this rule' button appears.
- Finally, there's still at least one bug in the Condition list... Select 'applies to one of more boards', then click a board name checkbox, then click a radio button above it. The button doesn't appear. That's because it only appears when you click the radio button first, and then any checkbox, not the other way around... That's a minor bug, but it's still a bug. It may apply to other situations in the condition list, but I don't have time to test them all, sorry, it's more of a job for our BETA TESTERs.......... :niark:
 1. And, by the way, what prevents us from renaming the Help template to 'Popup' and 'help_text' to 'popup_text'? I actually did this internally last night, before my network problems started... Because I'm feeling that the help popup is just one of many.
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on December 15th, 2012, 08:43 PM
* Triggering the popup is easy. Create a rule that has moderate or prevent as its action, and you'll get an extra option at the bottom to put in a message for the different languages. Put something in there. This is so when a rule triggers, the admin can explain to users what they did wrong. The popup is just a convenience in the admin area to show the admin what all the different languages are. (I can add screenshots of the whole process if that would help)
Quote
My problem comes from the fact that it only shows the Add button once you focus out of the box.
It was written that way, by me, deliberately back in February and it has *always* been that way since day 1. It's simply to not allow the user to actually add anything until there's something valid to add.
Quote
Also, the 'Informing the user' part shows up after you select the second dropdown. It should either show up before the condition list, or be shown only when the 'Save this rule' button appears.
No, it shouldn't, given that it only applies in two of the six possible things you can actually do in moderation filters. Locking/unlocking, pinning/unpinning do not trigger this message. Again, entirely by design.

As I see it, none of this is a bug. It's working exactly as I designed it to. Whether that means the design is wrong is a matter of debate, but if it changed, a lot more stuff has to be written to explain to the user what they're doing wrong. This way, they can't actually add a rule without conditions to it, they have to come up with a valid condition for a rule to add it to the rule and there must be a valid condition attached to be able to add the rule.
Quote
And, by the way, what prevents us from renaming the Help template to 'Popup' and 'help_text' to 'popup_text'? I actually did this internally last night, before my network problems started... Because I'm feeling that the help popup is just one of many.
It's still primarily used for the help text as far as I know (though the new say/ask might use it, haven't checked), and the only other uses are this popup and the who-liked-this popup, both of which are somewhat misappropriation of the help template by keeping the display logic inside the action itself rather than delegating it to some kind of template.
Title: Re: Extending the moderation filter actions when posting
Post by: Nao on December 16th, 2012, 11:49 PM
Quote from Arantor on December 15th, 2012, 08:43 PM
* Triggering the popup is easy. Create a rule that has moderate or prevent as its action, and you'll get an extra option at the bottom to put in a message for the different languages. Put something in there. This is so when a rule triggers, the admin can explain to users what they did wrong. The popup is just a convenience in the admin area to show the admin what all the different languages are. (I can add screenshots of the whole process if that would help)
I'm still not seeing the popup stuff, even after doing all of that.
I was expecting a '?' icon or something..?
Quote
It was written that way, by me, deliberately back in February and it has *always* been that way since day 1. It's simply to not allow the user to actually add anything until there's something valid to add.
But it should update after a first character was entered, rather than going out of the input area.
Quote
As I see it, none of this is a bug.
Surely the fact that selecting a board before selecting "all of these / all except these" won't trigger the button (even if ALL necessary entries are check) is actually a bug..?
Quote
It's working exactly as I designed it to. Whether that means the design is wrong is a matter of debate, but if it changed, a lot more stuff has to be written to explain to the user what they're doing wrong.
It doesn't need a rewrite, just a couple of tweaks...
Quote
It's still primarily used for the help text as far as I know (though the new say/ask might use it, haven't checked), and the only other uses are this popup and the who-liked-this popup, both of which are somewhat misappropriation of the help template by keeping the display logic inside the action itself rather than delegating it to some kind of template.
I'm just thinking that it's more logical to have a generic popup template like we do have a generic menu template, and then use that for the Help popups as well...
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on December 17th, 2012, 12:00 AM
Quote
I'm still not seeing the popup stuff, even after doing all of that.
I was expecting a '?' icon or something..?
If you've added a message, there will be a thing on the front page of moderation filters. The left hand column will say 'Moderate the post' and under it for that rule will be a link, '(and show a custom message)' which is that popup.
Quote
But it should update after a first character was entered, rather than going out of the input area.
Well, it triggers onchange, not onkeyup.
Quote
It doesn't need a rewrite, just a couple of tweaks...
That's a matter of opinion :P Basically, it is exactly how I designed it, even down to that little detail. Whether that's right or not is another question - it is OK if the design is wrong provided it's changed for the right reasons and everything else is done to support it.

The only problem with altering it in that fashion is that there's no user messages or anything, nor any logic to show any, in the event of the user trying to add something stupid. Thus it triggers onchange and only if there's something valid does it show anything. But it wasn't done out of laziness, it was to cause the user to stop a moment and check they'd put in what they meant to put in before they hit the add or save buttons respectively.
Quote
I'm just thinking that it's more logical to have a generic popup template like we do have a generic menu template, and then use that for the Help popups as well...
I pretty much abuse the help popup as that anyway, and all the popups I've done (oh, and the plugin readmes as well are shown that way) are done through abusing that template. Making a generic popup would be good.
Title: Re: Extending the moderation filter actions when posting
Post by: Nao on December 17th, 2012, 03:16 PM
Ah, got it, never actually SAVED a filter after building it... That's why I couldn't find the popup ;)

It may be triggered on change, but on my side it never triggers when typing text, only on focusout... Odd. Can you look into it?

How to reproduce what I really consider to be a bug:
- Create new filter
- Choose first in dropdown
- Choose first radio button
- Choose first in dropdown
- Click a checkbox (i.e. a board name), nothing happens, which is as intended I guess,
- Click a radio button (i.e. "applies to the selected"...), nothing happens, which is NOT as intended.

GenericPopup done :) It's not as slick as the Help stuff, but at least it's no longer a hack eheh...
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on December 17th, 2012, 03:35 PM
Quote
It may be triggered on change, but on my side it never triggers when typing text, only on focusout... Odd. Can you look into it?
Isn't that the definition of onchange for a textbox? I seem to recall onchange only ever triggering when you focusout, not every time there's a keypress.
Quote
Click a radio button (i.e. "applies to the selected"...), nothing happens, which is NOT as intended.
Yes it is. Until you actually select a board, the rule's not valid. It applies to the selected, but you haven't selected any, so this is a rule that is applicable to nothing, and thus useless.

There is no circumstance where a user should be legitimately creating a rule that happens on every post everywhere without *some* kind of qualification on it, even if it's only 'where user is not an admin'.
Title: Re: Extending the moderation filter actions when posting
Post by: Nao on January 5th, 2013, 03:13 AM
Quote from Arantor on December 17th, 2012, 03:35 PM
Yes it is. Until you actually select a board, the rule's not valid. It applies to the selected, but you haven't selected any, so this is a rule that is applicable to nothing, and thus useless.
Actually -- just re-read my step-by-step explanation: the board was indeed selected at that point.
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on January 5th, 2013, 04:11 AM
And did you select both a board and one of the radio buttons?

I couldn't reproduce it misbehaving.
Title: Re: Extending the moderation filter actions when posting
Post by: Nao on January 5th, 2013, 01:20 PM
Yes, I did... The 'trick' is to select the board(s) BEFORE you select the radio buttons. Clicking the radio buttons won't then trigger the button, and I have to re-check the boards for this to happen.
An easy fix would be to have a default radio button checked to begin with. Or fix the JavaScript ;)
This is with Chrome 26.x.
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on January 5th, 2013, 03:15 PM
I thought the code checked that? Been ages since I looked at it.
Title: Re: Extending the moderation filter actions when posting
Post by: Nao on January 5th, 2013, 05:05 PM
That's what I've been telling you for ages just the same :lol:
It doesn't work as intended, thus I thought you'd be eager to fix it. Or at least have a look at the code ;)
(I'd fix it myself, but I've never really looked into that particular page's source code and would rather give you dibbs.) ('Giving dibbs', does that work in English?)
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on January 5th, 2013, 06:11 PM
But it's always worked for me, I've never been able to make it not work, though I'll test it again in a bit.
Title: Re: Extending the moderation filter actions when posting
Post by: Nao on January 5th, 2013, 06:50 PM
Keep me posted.
Title: Re: Extending the moderation filter actions when posting
Post by: Dr. Deejay on January 6th, 2013, 12:15 AM
Don't know if this is intended behavior and if this has been said before (I searched, didn't find anything), however, when you add a rule that moderates the post when someone uses the f-word, the post will be moderated even when it is posted by an administrator. Yes, it does what it should do, but it doesn't really make sense when you can approve it anyway.

So my question is: is this intended behavior?
Title: Re: Extending the moderation filter actions when posting
Post by: Arantor on January 6th, 2013, 12:18 AM
Yes, this is absolutely intended behaviour. It may not be entirely logical to you, but it's doing *exactly* what you've told it - moderate the post because it contains a given word. If you don't want that behaviour to apply to admins, make an exclusion for them - moderate the post... if it contains a given word AND user is not in group Administrators.

Consider the other practical case - it would help discourage moderators from using profanities.
Title: Re: Extending the moderation filter actions when posting
Post by: Dr. Deejay on January 6th, 2013, 12:23 AM
Thanks for the explanation. ^_^ I was just wondering, that's why I asked. :)