[pmwiki-users] syntax question php for a Profiles.php
Crisses
crisses at kinhost.org
Sat Nov 18 09:54:44 CST 2006
On Nov 17, 2006, at 5:04 PM, The Editor wrote:
> On 11/17/06, Florian Fischer <Flori-Fischer at gmx.net> wrote:
>> Hello,
>>
>> i'm using Userauth and since i haven't found a possibility to
>> restrict the edit-access to the pages of a user, i try it with a
>> workaround. My Users have edit-rights for the Group Profiles. But
>> User B shouldn't be able to edit the pages of User A. There is no
>> automatic way to do this. I try it with a Profiles.php file
>>
>> $pagename = ResolvePageName($pagename);
>> $isAdminAuthorized = CondAuth($pagename, 'admin');
>> global $Author;
>> if (!$isAdminAuthorized) {
Your variables won't be parsed here:
>> if ($pagename != '{$Author}' || $pagename != '{$Author}-
>> Contribution' || $pagename != '{$Author}-Watchlist'){
either:
if ($pagename != "{$Author}" || $pagename != "{$Author}-
Contribution" || $pagename != "{$Author}-Watchlist"){
or:
if ($pagename != $Author || $pagename != $Author . "-
Contribution" || $pagename != $Author . "-Watchlist"){
And Caveman is right about the group names...you should use the
variable defined in pmwiki.php for defining the profiles group:
$AuthorGroup
so I would suggest that you try this:
$ThisProfile = "{$AuthorGroup}.$Author";
if ((!PageExists($ThisProfile)) || (!PageExists($ThisProfile . "-
Contribution")) || (!PageExists($ThisProfile . "-Watchlist")){
> Also, I'm not sure about using page variables directly in a local
> config file.
Did you know that "$var" and "{$var}" will both evaluate to the value
of $var in the string? this is valid PHP. Where I'm using
$AuthorGroup and $Author -- does "$AuthorGroup" become "XESGroup" or
"Profiles" ? So I save PHP the trouble of guessing and explicitly
tell it that the variable I'm looking for is the full $AuthorGroup
variable so
$ThisProfile = "{$AuthorGroup}.$Author";
echo $ThisProfile;
should say
Profiles.XES
I could have done:
$ThisProfile = $AuthorGroup . ".$Author";
but
$ThisProfile = "$AuthorGroup.$Author";
would be odd. I haven't tried it. I'm not sure how it would evaluate.
-- thus it's not page vars -- it's pure php :)
Crisses
More information about the pmwiki-users
mailing list