[pmwiki-devel] Feature requests

Eemeli Aro eemeli at gmail.com
Tue Sep 16 18:00:45 CDT 2008


I've come across a couple of things that I thought would be nice to
have added to the PmWiki core. Anyone else think these are good ideas?


=== Identifying the PageStore that a page has been read from
This wouldn't need much; when initialising you can already give a
PageStore custom attributes that are then included in the $page array.
However, there isn't any corresponding functionality when writing
pages to forget these default attributes. Hence if you first read a
page without an attribute, the default is loaded. If you then save
that page, the default is saved along with other data and hence will
overwrite any default value that is read on later access.

So could we have a "unset($page['dir']);" or something similar on line
923 of pmwiki.php, as well as including some value for this attribute
for the default wikilib.d directory, such that line 50 becomes for
example "$WikiLibDirs = array(&$WikiDir,new
PageStore('$FarmD/wikilib.d/{$FullName}',0,array('dir'=>'wikilib')));"?


=== Pick a PageStore to write to based on the group's main page
When you're writing a page and have more than one writable PageStore,
if the page is new it always gets written to the first available
PageStore. In such a case, how about also checking where the group's
main page has been written? This could be done by adding the following
before line 1008 of pmwiki.php:

  if ($i >= count($WikiLibDirs)) {
    $gn = MakePageName($pagename, preg_replace('/[^.]+$/','',$pagename));
    for($i=0; $i<count($WikiLibDirs); $i++) {
      $wd = &$WikiLibDirs[$i];
      if ($wd->iswrite && $wd->exists($gn)) break;
    }
  }


=== Match attachment read permissions with storage method
With the default settings, even though uploads are saved by group,
their access permissions are read from the page that you declare to be
accessing them from. So if you have a group 'Foo' that has a groupwide
read password, but it has a page 'Foo.Bar' which requires no read
password, Attach:Foo/file.ext will ask for your password but
Attach:Foo.Bar/file.ext won't.

To fix this, I've amended my scripts/upload.php file such that it
reads from line 161 as follows:

function HandleDownload($pagename, $auth = 'read') {
  global $UploadFileFmt, $UploadExts, $DownloadDisposition,
$GroupAttributesFmt, $EnableProtectUploadsByGroup;
  SDV($DownloadDisposition, "inline");
  if (IsEnabled($EnableProtectUploadsByGroup,0)) {
    SDV($GroupAttributesFmt,'$Group/GroupAttributes');
    $pagename = FmtPageName($GroupAttributesFmt, $pagename);
  }
  $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
  ...

eemeli



More information about the pmwiki-devel mailing list