Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

Recent Uploads Log

Summary: List all uploaded files in the RecentUploads pages
Version: 2007-03-12
Maintainer: Petko
Categories: Uploads, Administration

Questions answered by this recipe

How do I track every uploaded file in the RecentChanges and AllRecentChanges pages and easily review it?

Description

Every uploaded file is logged in the Group.RecentUploads pages with a link from (All)RecentChanges for easy review.

To install this recipe:

  • download recentuploads.phpΔ
  • copy it to your cookbook directory
  • add in your config.php or farmconfig.php this line:
    if(@$_REQUEST['action'] == 'postupload') { include_once("$FarmD/cookbook/recentuploads.php");}

The format logged in the (All)RecentChanges pages is as follows:

  • Group.RecentUploads . . . 2007-02-17 11:12:18 Petko : Page/Picture.png (123456 bytes)
  • Group2.RecentUploads . . . 2007-02-17 10:32:58 Petko : Page2/Picture2.png (6543 bytes)

where Page is a link to the wiki page where the file was attached, and Picture.png is a link to the file itself (click to download/review it).

Only the latest upload for a Group is displayed in RecentChanges, however, clicking on the link Group.RecentUploads will show you all uploaded files for the Group.

In a new special page RecentUploads (you can go there from the link at the RecentChanges page) are stored logs for all uploaded attachments in the format:

  • Page/Picture.png . . . 2007-02-17 11:12:18 by Petko (123456 bytes)
  • Page/Dissertation.odt . . . 2007-02-17 10:33:55 by Petko (77500 bytes)

Note that in the current PmWiki core, a page named RecentUploads will be excluded from page lists (with list=normal).

Changing the default logging format

(For advanced administrators.)

The default format is:

$RecentUploadsFmt['$SiteGroup.AllRecentChanges'] =
		'* [[{$Group}.RecentUploads]]  . . . $CurrentTime $AuthorLink :'
		.' [[{$Group}/{$Name}]]/[[(Attach:{$Group}.{$Name}/)$upname]] ($upsize)';
$RecentUploadsFmt['$Group.RecentChanges'] =
		'* [[{$Group}/RecentUploads]]  . . . $CurrentTime $AuthorLink :'
		.' [[{$Group}/{$Name}]]/[[(Attach:{$Group}.{$Name}/)$upname]] ($upsize)';
$RecentUploadsFmt['$Group.RecentUploads'] =
		'* [[{$Group}/{$Name}]]/[[(Attach:{$Group}.{$Name}/)$upname]]'
		.'  . . . $CurrentTime $[by] $AuthorLink ($upsize)';

To change the default format of what is printed in the RecentChanges and RecentUploads pages, you can change the $RecentUploadsFmt variable. It is the same as $RecentChangesFmt (see LayoutVariables#RecentChangesFmt) and will be used as an indication where to write the log and what information to include.

For example, to list every single upload in Site.AllRecentChanges, you can set something like this in config.php:

 $RecentUploadsFmt['$SiteGroup.AllRecentChanges'] =
  '* [[{$Group}.{$Name}]]/[[(Attach:{$Group}.{$Name}/)$upname]]'
  .'  . . . $CurrentTime $[by] $AuthorLink ($upsize)';

To unset one of the three default pages, where information is logged, set the following in config.php after the include_once() call.

To log nothing on Site.AllRecentChanges:

 unset($RecentUploadsFmt['$SiteGroup.AllRecentChanges']);

To log nothing on Group.RecentChanges:

 unset($RecentUploadsFmt['$Group.RecentChanges']);

Notes

  • The script will intercept a call to the $UploadVerifyFunction and if this function does not return an error, it will log the new file. This is done after a successfull upload to the server and all diskspace and filetype checks but before the actual moving of the file from the temporary directory to the upload wiki-directory and if eventually the "move" fails, in the RecentChanges there will be an attach:link to the non-existent file (you can click to re-upload it).
  • Naturally, only files uploaded after the installation of this recipe will be logged.

Release Notes

2007-03-12
changed the $RecentUploadFmt for a strategically better setting by default.
2007-02-17a
added the file size
2007-02-17
initial release

Comments

Changing the name of this recipe means the SiteAnalyzer cannot compare versions

See Also

Contributors

Edit - History - Print - Recent Changes - Search
Page last modified on July 26, 2008, at 07:56 PM