[dokuwiki] Re: Restricting actions

On Sun, 02 Jul 2006 11:05:19 +0100
Chris Smith <chris@xxxxxxxxxxxxx> wrote:

> My initial instinct is that the button and action link code should
> take  this config option into account, either to
> - when the button/link is requested, to output in such a form that it
> is  clearly disabled.
> - or to output nothing.

I went for the latter.
 
> To me it would seem odd if DokuWiki could generate an apparently
> working  button/link which actually does nothing.
> 
> How are you implementing this ... the action handler checks the action
> against the disabled string and doesn't process any action for which 
> there is a match?  Some other method?

Yes exactly like this. Disabled actions are changed to 'show' and a
a warning is printed. This means you can't disable the show action but
this would be pretty useless anyway.

I created an actionOK() function to test if an action is enabled or
disabled. This function is called in the action handler but also on some
other places. Most importantly in the tpl_button and tpl_actionlink
functions. In those functions I also check the type with the actionOK
method which is mostly the same as the internal action. But this has the
side effect that you can disable buttons which don't have an according
action. Eg. adding 'top' to the disableactions option disables the
"Back to top" button. For disabling the source view I added the pseudo
action 'source'.

> As an aside, once this is complete, I will write a class for config 
> manager to specially handle it.  Probably generating checkboxes for
> each  action which can be disabled.

Great. I didn't touch the config plugin to not interfere with you. The
question is which actions should be allowed to disable by the config
manager. Disabling some may break things (eg. disabling 'conflict')
others should always be disabled together (eg. source and export_raw).
So it makes sense to give only useful choices to the user.

> It would be handy if somewhere
> DokuWiki  maintained a list of possible actions - a list that plugins
> that provide  extra actions could add to.  Making it conceivable that
> a dokuwiki  installation could have custom actions which could be
> disabled in a  similar fashion to DokuWiki actions - although I admit
> it may make more  sense to disable the plugin.

This could be complicated because of the restrictions mentioned above.

Andi

Other related posts: