[pmwiki-users] setting $Author with $AuthId as prefix

Patrick R. Michaud pmichaud at pobox.com
Mon Jan 22 10:00:07 CST 2007


On Mon, Jan 22, 2007 at 05:24:41PM +1100, Kathryn Andersen wrote:
>         include_once("$FarmD/scripts/author.php");
>         include_once("$FarmD/scripts/authuser.php");
>         # The author is prepended with the authId
>         # To make this easier, use '-' as a separator
>         # AuthId-Author
>         if ($Author) {
>             if (strstr($Author, '-') != false) {
>                 $auth_split = explode('-', $Author, 2);
>                 $Author = $AuthId . '-' . $auth_split[1];
>             } else if ($Author != $AuthId) {
>                 $Author = $AuthId . '-' . $Author;
>             } else {
>                 $Author = $AuthId;
>             }
>         } else {
>             $Author = $AuthId;
>         }

Simpler is:

    include_once("$FarmD/scripts/author.php");
    include_once("$FarmD/scripts/authuser.php");
    $Author = "$AuthId-" . preg_replace('/^[^-]*-/', '', $Author);

> - the Recent Changes page says that the change was made by "Kathryn".
>   (bad)
> ...
> So why isn't the "userid-Kathryn" being used in the Recent Changes page
> in case A?

The RecentChanges pages use $AuthorLink (not $Author) for
generating the attributions in each entry.  $AuthorLink is
set by author.php -- which for a first-time login is happening
before the $AuthId manipulations a bit later.

Simply be sure to also (re)set $AuthorLink when changing $Author:

    include_once("$FarmD/scripts/author.php");
    include_once("$FarmD/scripts/authuser.php");
    $Author = "$AuthId-" . preg_replace('/^[^-]*-/', '', $Author);
    $AuthorLink = "[[~$Author]]";

Pm




More information about the pmwiki-users mailing list