[pmwiki-users] New recipe: Fox

marc gmane at auxbuss.com
Thu Dec 21 06:03:08 CST 2006


Hans said...
> Wednesday, December 20, 2006, 2:22:01 PM, marc wrote:
> 
> > By removing
> 
> >   $Author = $AuthId;
> 
> > I can force author.php to set author from $_POST['author'] and create a
> > comment while not logged in.
> 
> > This is not solution, because removing $Author = $AuthId will break 
> > other things.
> 
> I use in config.php:
> 
> include_once("$FarmD/scripts/authuser.php");
> 
> if ($AuthId) {
>   $Author = $AuthId;
>   setcookie('author',$Author,0,'/');
> }
> include_once("$FarmD/scripts/author.php");
> 
> so $Author = $AuthId; is only set if authuser.php is loaded (which
> defined $AuthId).

I think I can just replace

  $Author = $AuthId;

with

  if ($AuthId) $Author = $AuthId;

since this problem stemmed from RequireAuthor(), which is part of 
author.php.

(If this is correct, then perhaps the docs should be changed: AuthUser/
#Setting the Author Name)

> Re: Fox
> Fox does not do anything with the author value. In the commentbox
> example the author value is simply used in the template to fill in a
> name in the message header. And it is conveniently populated with
> {$Author} in the form.

Yup, but Fox leans on the implied functionality that setting $Author 
brings (from using $_POST['author']), so we need to make sure that the 
expected behaviour is consistent.

I think that we have tripped over an outstanding anomaly from the 
introduction of UpdatePage(), as the stuff that follows indicates. But 
hey, what do I know?

> Still it is perplexing that saving  a post or deleting  a post is not
> possible when no author is defined, even when both authuser.php and
> author.php are not loaded. I find that it seems to depend on
> 
> $EnablePostAuthorRequired = 1;
> 
> setting it to zero or commenting the line makes it possible to post
> and to delete posts with fox, even with no author supplied.

It's used in author.php

  if (IsEnabled($EnablePostAuthorRequired,0))
    array_unshift($EditFunctions,'RequireAuthor');

and since this ($EditFunctions) is the array that UpdatePage() iterates 
over

  if (is_null($fnlist)) $fnlist = $EditFunctions;
  ...
  foreach((array)$fnlist as $fn) $fn($pagename, $page, $new);

then setting 

  $EnablePostAuthorRequired = 0;

will stop UpdatePage() running RequireAuthor() - the root of my original 
problem - and thus the post can be made.

> Fox is doing very little or nothing to validate field input.
> CommentBoxPlus is still more clever there, as it checks at least via
> javascript if you have entered text and an author name.

Yes, I use CommentBoxPlus a little, and it is Fox's lack of JS that I 
first liked.

> It is easier
> to program since the form gets defined within the script.
> Fox on the other hand relies on the PmWiki Input controls.
> One can develop customised versions which will use minimum javascript
> input validation. But this is not up to Fox.

Yup, and those are the other reasons I like it. Thanks very much for 
writing it.

-- 
Best,
Marc





More information about the pmwiki-users mailing list