Tuesday, January 3, 2012

Displaying metadata field as checkbox

I think most of us knows how to Customize Oracle UCM 11g menus, and if not take a look at other blog posts like form this one from Kyle's blog: Modifying Navigation Menus in UCM 11g

But what if you want the menus to be based on Custom security roles that you have created, unfortunately it is not available out of the box. In the following lines, I will explain how to do that:

- When created your menus, you have overridden a resource include called CoreMenuItemsFlags
For example:


<@dynamicdata CoreMenuItemsFlags@>
id, flags
FUNCTIONA, isAdmin
<@end@>

- Instead of using predefined permissions based on fixed roles like isAdmin, isLoggedIn, or isSysManager, we need to use permissions based on our custom roles also we need to write code once (I mean we will not change our custom code for every new role created).

- My approach is: if we have a new custom role called HR, then we will use a permission for the menu called isUserInSpecificRoleBillingAuditorHR, so the resource include will be


<@dynamicdata CoreMenuItemsFlags@>
id, flags
FUNCTIONA, isUserInSpecificRoleBillingAuditorHR
<@end@>

- Now the real story comes
We will customize a resource include called navigation_filter_rset_menu_item where we will add an extra check for our prefix isUserInSpecificRoleBillingAuditor, and according to the Role added to the prefix we grant users access to the menu item


<$elseif flags like "*isUserInSpecificRole*"$>
<$if strIndexOf(flags, ':') == -1$>
<$userInRole = strSubstring(flags,20,strLength(flags))$>
<$else$>
<$part1 = strSubstring(flags,strIndexOf(flags,'isUserInSpecificRole')+20,strLength(flags))$>
<$if strIndexOf(part1, ':') == -1$>
<$userInRole = part1$>
<$else$>
<$userInRole = strSubstring(part1,0,strIndexOf(part1, ':'))$>
<$endif$>
<$endif$>
<$if not userHasRole(userInRole)$>
<$tmpDeleteRow = 1$>
<$endif$>

Note the extra check should be added after isContributor check

<$if flags like "*isContributor*"$>

Or you can read the resource include code and customize it as you want


No comments: