|
Cookbook /
CMSLikeSummary: 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
Categories: Administration, CMS
Question answered by this recipeTo make PmWiki behave as a CMS, by showing only the actions the current user is allowed to perform. FilesContaining:
DescriptionThis 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 RequirementsIt 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
#$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 !
The cmslike.tmpl file is a sample template based on pmwiki.tmpl. You can just substitute it to pmwiki.tmpl to get it working. ConfigurationThe following variables can be defined before cmslike.php is included in config.php:
Notes
History
Author and Contributors
CopyrightCopyright 2005 by DidierLebrun, under the GNU GPL License Comments & BugsBelow this line, please. March 13, 2005
March 14, 2005Thanks for your review. I'm pleased you like it and adopted it straight away :) I've not taken the time yet to review the changes in UserAuth version 0.6 and their impact on CMSLike, but I'll do it as soon as possible. You're true about the function + variable calls in the template. I was aware of that, but neglected it in the first release. ... A few hours later, the CMSLike version 0.2 is released, with all the wanted functionalities in,... I hope so anyway ;) -- DidierLebrun March 15, 2005I upgraded to version 0.2 and noticed that the pwchange button would show up whenever I was logged out. This was the result of how you were checking abilities. I then changed CMSLike to do the following at around line 130:
if( UserAuth($pagename, $level, false) ) {
Instead of this:
$userauth_level = CmsLikeUserAuthLevel($level, $group, $name);
if($UserInfoObj->UserHasAbility($username, $userauth_level)
|| $UserInfoObj->UserHasAbility($GuestUsername, $userauth_level)
|| $UserInfoObj->UserHasAbility($LoggedInUsername, $userauth_level)
|| $UserInfoObj->UserHasAbility($username, $level.'_all') ) {
I realized upon doing this that there was a bug in UserAuth where an error message could be displayed inside the CheckUserAuthPassword function. I fixed this bug and now your CMSLike module can directly call the UserAuth function for checking the permissions of each level just as I have shown above. Hopefully, this will make CMSLike better able to deal with any changes to UserAuth in the future. Hope this helps. -- JamesMcDuffie One more thing, is it possible for CMSLike to preserve the order that a user defines menu items in? For instance, I like having my edit link at the very left, but instead print is the left most item -- JamesMcDuffie March 17, 2005Your idea of simply delegating auth processing to UserAuth instead of implementing a parallel behavior is bright ! I wander why I didn't think of it before ? The script is much leaner and cleaner like that :) In the meantime, I realized I had forgotten the line for disabling the create links when the user doesn't have edit rights in version 0.2, although it was there in 0.1. So I put it back in place. I changed the output processing too, so as to keep the configured menu items order. With all these changes, I made version 0.3. Thanks again for your debugging and suggestions --DidierLebrun March 17, 2005Great addon! I still can't get the edit links to disappear, any help? Could you tell a bit more about your config ?--DidierLebrun I haven't changed much. I've included userauth, admintool, pwchange and cmslike in config and set $Skin to cmslike. I've turned off LinkWikiWords and rewrite URLs to be pretty. Cmslike is version 0.3. You can se the site at http://spiser.pylse.cx/~krav/wikii/(approve links), there's a test user with password test. --Kristoffer? Ok. I see the problem. I made a small modification after testing, and introduced a bug. I've fixed it in version 0.31 --DidierLebrun Great, it works with WikiWords, but not with links like this?. See my wiki for an example. -- Kristoffer? That's true ! I found the bug and fixed it in version 0.32 --DidierLebrun How about moving the list of actions into $Actions = array(
'print' => 'Printable View',
'history' => 'Page History',
'edit' => 'Edit Page',
'upload' => 'Upload',
'attr' => 'Attributes',
'rename' => 'Rename Page'
'admin' => 'UserAuth Admin',
'pwchange' => 'Change Password',
);
include_once('local/rename.php');
include_once('local/userauth.php');
include_once('local/changepw.php');
Currently, I must consistently update both Joachim Durchholz March 20, 2005, at 05:34 AM I don't understand your point in relation with CMSLike, since CMSLike does actually replace the actions menu in the template by a single function call, and does manage the actions menu in config vars !? - DidierLebrun March 26, 2005 Sorry for being obtuse. I meant that this functionality belongs to the PmWiki core, so that skin writers can rely on it. Joachim Durchholz April 04, 2005, at 06:25 AM There are advantages, but drawbacks too in integrating optional features in the core package. It's a complex philosophical question, with lots of side effects to consider. Usually, free software projects prefer the more modular approach of independant and complementary sub-projects, since it relieves the maintainers of the main project from having to take care of too many things when releasing a new version. - DidierLebrun April 5, 2005 Very Nice, Thankyou! I would like to see the logout option be an available CmsLikeMenuOption It's a good idea. You can actually do that with the current version by adjusting a bit the config vars, but I'll integrate it in the default config in next version. - DidierLebrun April 5, 2005 Insert to I use PmWiki as a CMS and don't bother with conditional edit links. I used a bookmarklet in my browser so I can click on the bookmark for ANY PmWiki page I want to edit -- saves me from hunting the Edit Page link down (scrolling up and down looking for it) or typing the variable & value into the URL. See OtherBookmarklets I do know this won't work for everyone -- but it can be a timesaver whether or not you have edit page links on the page. --XES The menu did disapeared when I replaced pmwiki.tmpl with cmslike.tmpl, after aplieing this fix, the left menu works. |