[opencms-dev] OpenCms Administration Tools/Roles HOW-TO

Arash Kaffamanesh arash.kaffamanesh at pomegranate.de
Thu Oct 20 16:55:59 CEST 2005


Hi Michael,

Great Post, thanks a lot. Such a great post belongs also into the
forum(s):

http://www.pomegranate.de:9000/cms/forum/viewthread?thread=29

I hope you permit.

Thanks again,
Arash

-----Original Message-----
From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Michael Moossen
Sent: Donnerstag, 20. Oktober 2005 13:05
To: opencms-dev at opencms.org
Subject: [opencms-dev] OpenCms Administration Tools/Roles HOW-TO


Hi, All!

To programmatically set the visibility and/or enabled flags for
administration tools.

Create a new tool handler extending
org.opencms.workplace.tools.A_CmsToolHandler,
for this you will need to implement 2 methods: isEnabled(CmsObject) and
isVisible(CmsObject)

In these methods you can use the CmsObject.hasRole(CmsRole) method. as
for
example:
-------------
public class SampleToolHandler extends A_CmsToolHandler {
    public boolean isEnabled(CmsObject cms) {
        return cms.hasRole(CmsRole.ADMINISTRATOR);
    }
    public boolean isVisible(CmsObject cms) {
        return cms.hasRole(CmsRole.VFS_MANAGER);
    }
}
-------------
This tool will be visible for users having the VFS_MANAGER role, but
only enabled for users with the ADMINISTRATOR role.

Then, set the 'admintoolhandler-class' property of the tool in question
to your new class name, and be sure to place your class somewhere your
servlet container can find it.

To keep in mind: all the properties related to the admin tools are only
read during the workplace initialization process. it is not enough to
change the value to see a change in behaviour. you have to reinitialize
the workplace.

but what is if no system role (defined in the
org.opencms.security.CmsRole
class) fits your needs 100%?
Just create a new role, for instance:
-------------
public static final CmsRole SAMPLE = new CmsRole("SAMPLE", "Sample
Group", new CmsRole[] {CmsRole.ADMINISTRATOR});
-------------
Every direct or indirect member of the "Sample Group" group will have
this role, and also everybody having the ADMINISTRATOR role.

PD: some day it will be an administration tool to administrate the
roles.

-- 
Regards
Michael Moossen

Alkacon Software GmbH - The OpenCms Experts http://www.alkacon.com


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



_______________________________________________
This mail is send to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please
visit http://mail.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list