[pmwiki-users] Re: Restricting information (Was: General Farming Questions)

chr at home.se chr at home.se
Tue Oct 4 10:56:04 CDT 2005


On Mon, 3 Oct 2005 chr at home.se wrote:

Neil wrote:
> Thanks Christian. I wish I spoke more "PHPese" so that I could 
> understand what the code snippet does.

My PHPese could also be better... for the benefit of anyone listening, 
here's what I think is happening:

> // Modify page library search, making some groups common for the farm
> if(true) {

I've just wrapped the whole thing in 'if(true) { ... }' to make it easy to 
disable it when debugging. Just ignore it.

>   $WikiLibDirs = array(&$WikiDir, 
>                        new PageStore("$FarmD/shared.d/\$FullName"),
>                        new PageStore('$FarmD/wikilib.d/$FullName'));

Pmwiki looks in several "library directories" when searching for a page.  
The line above sets this array to:
1. A *reference* to the variable that says where pages are to be saved
2. The directory $FarmD/shared.d  (which I've created separately I think)
3. The directory $FarmD/wikilib.d (for pages in the group PmWiki/ etc)

The reference bit means that if/when $WikiDir is changed, pmwiki will look 
in the directory that's currently referenced by $WikiDir - not the value 
of $WikiDir when this code is executed.

>   // Force use of directory shared.d/ for edits to the group 'Site' etc
>   $group = FmtPageName('$Group', $pagename);

Get the name of the current group

>   if(($action == 'edit' && ($group == 'Site' ||
>                             $group == 'Profiles' ||
>                             $group == 'Playground' ||
>                             $group == 'PmWiki' ||
>                             $group == 'Test')) ||
>      ($action == 'approvesites') ||
>      ($action == 'approveurls')) {

We're checking a condition here. One of the following needs to be true:
* We're editing a page in one of the following groups:
	'Site/', 'Profiles/', 'Playground/', 'PmWiki/' or 'Test/'
  (These are the groups which will be shared)
* We're approving a site (only needed if urlapprove.php is used)
* We're approving a URI (only needed if urlapprove.php is used)

When one of the conditions above is satisfied, then do the following:

>     $WikiLibDirs[] = $WikiDir;

Set the library path to only be the *current* value of '$WikiDir'.

>     $WikiDir = new PageStore("$FarmD/shared.d/\$FullName");

Set the path to where pages should be stored to $FarmD/share.d/.

I hope this helps!

/Christian

PS. When I write this, I have to say that I wonder why I'm changing 
$WikiLibDirs the way I do... anyone have an idea?

-- 
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr






More information about the pmwiki-users mailing list