CMSLike

Summary: Make PmWiki behave as a CMS by showing only the actions the current user is allowed to perform
Version: 0.32
Prerequisites: UserAuth
Status:
Maintainer: Didier Lebrun
Discussion: CMSLike-Talk
Categories: Administration, CMS

Question answered by this recipe

To make PmWiki behave as a CMS, by showing only the actions the current user is allowed to perform.

Files

Containing:
  • cookbook/cmslike.php
  • pub/skins/cmslike/cmslike.tmpl

Description

This PmWiki plugin builds dynamic actions menus, depending on the current user rights, according to UserAuth, so the user will only be presented the actions he can perform. It disables the WikiWords create links too in the text when the user is not allowed to edit.

Note: This recipe can be regarded obsolete in the sense that the same functionality (user dependent action links) can be obtained meanwhile more flexibly also with pmwiki built-in means, using conditional markup (:if auth edit:) [[Edit -> ?action=edit]] (:if:) for example in Site.PageActions. ThomasP April 18, 2007, at 04:18 AM

Requirements

It relies on UserAuth, and requires it of course. There is no point anyway to use this plugin if you don't use UserAuth.

Apart from UserAuth, there is no other requirement. It doesn't require several templates, contrarily to another CMS like recipe (see PmWikiAsACMS) and can be used with any templates, including PmWiki standard one.

Installation

  • copy cmslike.php in your cookbook directory
  • add the following lines in your local/config.php file and adjust them to your taste:
 
 #$CmsLikeMenuItems = array(
 # 'print' => '<a href="$PageUrl?action=print" target="_blank"
 #      rel="nofollow">$[Printable View]</a>',
 # 'history' => '<a href="$PageUrl?action=diff"
 #      rel="nofollow">$[Page History]</a>',
 # 'edit' => '<a href="$PageUrl?action=edit"
 #      rel="nofollow">$[Edit Page]</a>',
 # 'upload' => '<a href="$PageUrl?action=upload"
 #      rel="nofollow">$[Uploads]</a>',
 # 'attr' => '<a href="$PageUrl?action=attr"
 #      rel="nofollow">$[Attributes]</a>',
 # 'admin' => '<a href="$PageUrl?action=admin"
 #      rel="nofollow">$[UserAuth Admin]</a>',
 # 'pwchange' => '<a href="$PageUrl?action=pwchange"
 #      rel="nofollow">$[Change Password]</a>');
 #$CmsLikeMenuSep = ' ';
 #$CmsLikeAltMenuItems = $CmsLikeMenuItems;
 #$CmsLikeAltMenuSep = ' - ';
 include_once('cookbook/cmslike.php'); # you need this !
 
  • in your template:
    • replace your static actions menu with <!--function:CmsLikeMenuFmt--> for the standard menu setup
    • ... or with <!--function:CmsLikeMenuFmt alt--> for the alternate menu setup

The cmslike.tmpl file is a sample template based on pmwiki.tmpl. You can just substitute it to pmwiki.tmpl to get it working.

Configuration

The following variables can be defined before cmslike.php is included in config.php:

  • $CmsLikeMenuItems : HTML strings used in the actions menu
  • $CmsLikeMenuSep : separator to be inserted between two menu items
  • $CmsLikeAltMenuItems : alternate menu definition strings
  • $CmsLikeAltMenuSep : alternate menu separator string

Notes

  • UserAuth interception is used for calling CmsLikeMakeActionsList when the group is known, so as to establish the relevant rights. The conditions reproduce UserAuth ones.
  • <!--function:CmsLikeMenuFmt[ alt]--> in the template is used to evaluate the variables when they are fully defined.
  • You can use the "alt" optional arg to get the alternate menu setup instead of the standard (default) one, so you can have 2 different layouts in the same page (ex: a vertical one and an horizontal one like those in PmWiki default template)

History

  1. March 11, 2005: Version 0.1
    1. Initial version
  2. March 14, 2005: Version 0.2
    1. Change $_SESSION[...] calls to $UserInstanceVars->... (see userauth-0.6 changes)
    2. Added page level auth conditions (see userauth-0.6 changes)
    3. Rewrote auth processing to be cleaner and more adaptative to changes
    4. Added Admin Tool and Change Password actions (see userauth-admintool and userauth-pwchange)
    5. Change the template tags to <!--function:CmsLikeMenuFmt[ alt]--> (adjust your template !)
    6. Fixed a potential bug when the configured $CmsLikeMenuItems lacks some actions
  3. March 17, 2005: Version 0.3
    1. Delegate auth processing to UserAuth (thanks to JamesMcDuffie)
    2. Restore create link disabling depending on edit rights (disappeared by mistake in 0.2 !)
    3. Keep $CmsLikeMenuItems and $CmsLikeAltMenuItems configured order for display
  4. March 18, 2005: Version 0.31
    1. Fixed create link disabling
  5. March 23, 2005: Version 0.32
    1. Fixed create link disabling on spaced words

Author and Contributors

Copyright

Copyright 2005 by DidierLebrun, under the GNU GPL License

Comments

See discussion at CMSLike-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.