Question answered by this recipe
To make PmWiki behave as a CMS, by showing only the actions the current user is allowed to perform.
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
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.
- 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
- replace your static actions menu with
The cmslike.tmpl file is a sample template based on pmwiki.tmpl. You can just substitute it to pmwiki.tmpl to get it working.
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
- 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)
- March 11, 2005: Version 0.1
- Initial version
- March 14, 2005: Version 0.2
- Change $_SESSION[...] calls to $UserInstanceVars->... (see userauth-0.6 changes)
- Added page level auth conditions (see userauth-0.6 changes)
- Rewrote auth processing to be cleaner and more adaptative to changes
- Added Admin Tool and Change Password actions (see userauth-admintool and userauth-pwchange)
- Change the template tags to <!--function:`CmsLikeMenuFmt[ alt]--> (adjust your template !)
- Fixed a potential bug when the configured $CmsLikeMenuItems lacks some actions
- March 17, 2005: Version 0.3
- Delegate auth processing to UserAuth (thanks to JamesMcDuffie)
- Restore create link disabling depending on edit rights (disappeared by mistake in 0.2 !)
- Keep $CmsLikeMenuItems and $CmsLikeAltMenuItems configured order for display
- March 18, 2005: Version 0.31
- Fixed create link disabling
- March 23, 2005: Version 0.32
- Fixed create link disabling on spaced words
Author and Contributors
- DidierLebrun - Primary author and maintainer
Copyright 2005 by DidierLebrun, under the GNU GPL License
See discussion at CMSLike-Talk