SharedPages-Talk

Summary: Talk Page for SharedPages recipe
Maintainer: Pm
Hi, I've written a quick recipe that creates the ?action=share and =unshare function. A very tiny script (ten real lines), that pushes the file from wiki.d to ../shared.d and vice versa in my farm. You still create the new page in a local wiki, but once the page is made you just run the ?action=share function to 'share' it. Running ?action=unshare moves the file out of the shared.d folder back to the local wiki. It's not much, but it addresses the problem without too much work. 2006-Jun-13 JacobMunoz
      <?php if (!defined('PmWiki')) exit();
     SDV($HandleActions['share'], 'HandleShare');
     SDV($HandleAuth['share'], 'edit');
     function HandleShare($pagename) {
        rename("wiki.d/$pagename","../shared.d/".basename($pagename));
        Redirect($pagename);  }
     SDV($HandleActions['unshare'], 'HandleUnshare');
     SDV($HandleAuth['unshare'], 'edit');
     function HandleUnshare($pagename) {
        rename("../shared.d/$pagename","wiki.d/".basename($pagename));
	 Redirect($pagename);  }
     ?> 

Shared groups

Here is a working example for sharing groups of pages, where all new pages in the shared group are placed in the shared group directory (noting the use of Per Group Sub Directories for wiki.d and sharedwiki.d page stores).

In the following path was replaced by ../../.. in the working configuration.

In config.php (for the website with the sharedwiki.d directory)

  $WikiDir = new PageStore('wiki.d/$Group/$FullName'); # writeable directory per group page store
  $WikiLibDirs = array( &$WikiDir,
     new PageStore('$FarmD/wikishared.d/$Group/$FullName', 0), # readable directory per group pagestore
     new PageStore('$FarmD/wikilib.d/$FullName')); # PmWiki default pages

In config.php (for the website wanting to access the sharedwiki.d directory)

  $WikiDir = new PageStore('wiki.d/$Group/$FullName'); # writeable directory per group page store
  $WikiLibDirs = array( &$WikiDir,
     new PageStore('$FarmD/path/wikishared.d/$Group/$FullName', 0), # readable directory per group pagestore
     new PageStore('$FarmD/wikilib.d/$FullName')); # PmWiki default pages

This lets the shared pages to be read (eg by page lists, searches).

In the SharedGroup.php (for the website with the sharedwiki.d directory)

 ## only alter the directories when a page is posted in this group
 if (@$_REQUEST['action']=='edit'
  && preg_grep('/^post/', array_keys($_REQUEST) ) ) {
   $LockFile = "$FarmD/wikishared.d/.flock"; # set lockfile to shared group
   $WikiDir = new PageStore('$FarmD/wikishared.d/$Group/$FullName', 1); # writeable shared directory per group pagestore
   $WikiLibDirs = array( &$WikiDir,
     new PageStore('wiki.d/$Group/$FullName', 1), # writeable directory per group pagestore
     new PageStore('$FarmD/wikilib.d/$FullName') ); # PmWiki default pages
 }

In the SharedGroup.php (for the website wanting to access the sharedwiki.d directory)

 ## only alter the directories when a page is posted in this group
 if (@$_REQUEST['action']=='edit'
  && preg_grep('/^post/', array_keys($_REQUEST) ) ) {
   $LockFile = "$FarmD/path/wikishared.d/.flock"; # set lockfile to shared group
   $WikiDir = new PageStore('$FarmD/path/wikishared.d/$Group/$FullName', 1); # writeable shared directory per group pagestore
   $WikiLibDirs = array( &$WikiDir,
     new PageStore('wiki.d/$Group/$FullName', 1), # writeable directory per group pagestore
     new PageStore('$FarmD/wikilib.d/$FullName') ); # PmWiki default pages
 }

The wiki.d directory is set writeable to allow some Site and SiteAdmin group pages to be written (eg RecentChanges, Site.AllRecentChanges, Blocklist pages (Chongqed etc)).

Simon September 15, 2009, at 08:17 PM

Talk page for the SharedPages recipe (users).