[pmwiki-users] parameters to a handler function

Petko Yotov 5ko at 5ko.fr
Sat Jul 9 02:00:52 CDT 2016

On 2016-07-09 03:12, Peter Kay wrote:
> So let me check my understanding: If I set
> HandleAuth['myaction']='edit';

I'd probably set:

   SDVA($HandleAuth, array('myaction'=>'edit'));

(SDVA() = Set default value in array if unset, don't change other array 
entries; SDV()=Set default value if unset, see "PmWiki/Functions").

This way, if an admin sets $HandleAuth['myaction']='edit'; before 
including your recipe, her settings will not be overwritten by your SDVA 

She could set the permissions before or after including the recipe.

Same with other configurable values in your recipe.

> And then do
> function MyActionCallback($pagename, $auth) {
>   $page=RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
>   #Abort if no page, etc
> }
> Then a user would need to have edit permissions to do 'myaction',

Yes. The user will see the login prompt until he provides the 'edit' 

> unless the wiki admin somehow unset HandleAuth['myaction'], right?

Yes, she may have increased the restriction ('admin'), lowered it 
('read'), or disabled it it ('ALWAYS').

> Alternately, if you make your callback look like this:
> function MyActionCallback($pagename) {
>   $page=RetrieveAuthPage($pagename, 'edit', true, READPAGE_CURRENT);
>   #abortetc
> }
> then a user has to have 'edit' permissions, right?

Yes, this will not allow the admin to adapt the permissions. If you have 
reasons to do it this way, you can.

If it is not configurable, the admin could anyway modify your script if 
she needs it. But there is the PmWikiPhilosophy (for the core, but also 
for many recipes) that an admin should not "need" to modify scripts, as 
this would make it harder to upgrade to a newer version - she would have 
to re-apply her changes every time she upgrades. If the setting can be 
made configurable, she could simply drop the new version and her 
installation would hopefully continue to work as before. :-)


Change log     :  http://www.pmwiki.org/wiki/PmWiki/ChangeLog
Release notes  :  http://www.pmwiki.org/wiki/PmWiki/ReleaseNotes
If you upgrade :  http://www.pmwiki.org/wiki/PmWiki/Upgrades

More information about the pmwiki-users mailing list