« Hooks
Extending the moderation filter actions when posting

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
Extending the moderation filter actions when posting
« 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?
A confident man keeps quiet.whereas a frightened man keeps talking, hiding his fear.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Extending the moderation filter actions when posting
« Reply #1, 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.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Extending the moderation filter actions when posting
« Reply #6, 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.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Extending the moderation filter actions when posting
« Reply #7, 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.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Extending the moderation filter actions when posting
« Reply #8, 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...

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Extending the moderation filter actions when posting
« Reply #9, 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.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Extending the moderation filter actions when posting
« Reply #10, 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...

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Extending the moderation filter actions when posting
« Reply #11, 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'.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Extending the moderation filter actions when posting
« Reply #12, 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.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Extending the moderation filter actions when posting
« Reply #14, 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.