Foros de discusión

How to hide default roles for other users?

thumbnail
Mani kandan, modificado hace 12 años.

How to hide default roles for other users?

Expert Mensajes: 492 Fecha de incorporación: 15/09/10 Mensajes recientes
Hi all,

Liferay has default Roles (Administrator,Community Content Reviewer,Community Administrator etc.,) and default User(test).

I want to hide all default roles and default user for "Admin" which i have created. That is, "Admin" can able to add new users, new roles but he cant able to view default roles and user.

I want to do this in \html\portlet\enterprise_admin\view_roles.jsp file which is displaying all the roles.

How to achieve it?
nidheesh ks, modificado hace 12 años.

RE: How to hide default roles for other users?

New Member Mensajes: 23 Fecha de incorporación: 26/07/11 Mensajes recientes
Hi,

I think you can create a custom_jsp hook for this and hide roles you dont want to show.
thumbnail
Mani kandan, modificado hace 12 años.

RE: How to hide default roles for other users?

Expert Mensajes: 492 Fecha de incorporación: 15/09/10 Mensajes recientes
I know it will do by the help of hook. But i dont know what code should i use for that ?
thumbnail
Mani kandan, modificado hace 12 años.

RE: How to hide default roles for other users?

Expert Mensajes: 492 Fecha de incorporación: 15/09/10 Mensajes recientes
Any help?emoticon
thumbnail
Sreeraj AV, modificado hace 12 años.

RE: How to hide default roles for other users?

Regular Member Mensajes: 239 Fecha de incorporación: 27/04/10 Mensajes recientes
Mani kandan:
Any help?emoticon


modify html\portlet\enterprise_admin\view_roles.jsp

<%@page import="com.liferay.portlet.admin.util.OmniadminUtil"%>
<%
List resultRows = searchContainer.getResultRows();

for (int i = 0; i < results.size(); i++) {
Role role = (Role)results.get(i);
if( OmniadminUtil.isOmniadmin(user.getUserId())|| role.getRoleId()!=10138 ){ //Checking whether role is liferay predefined using the primary key: Change 10138 wth the correct liferay default role

role = role.toEscapedModel();

// remaing code....
// remaing code....
// remaing code....


// Add result row

resultRows.add(row);
}
}
%>

<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />





or u can use this idea also.. the main difference is here we are checking with the role names..



<%@page import="com.liferay.portlet.admin.util.OmniadminUtil"%>
<%
List resultRows = searchContainer.getResultRows();

for (int i = 0; i < results.size(); i++) {
Role role = (Role)results.get(i);
String name= role.getName();
if( OmniadminUtil.isOmniadmin(user.getUserId())|| (!name.equals(RoleConstants.ADMINISTRATOR) && !name.equals(RoleConstants.COMMUNITY_ADMINISTRATOR) && !name.equals(RoleConstants.COMMUNITY_OWNER) && !name.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR) && !name.equals(RoleConstants.ORGANIZATION_OWNER)) ){ //Checking whether role is liferay predefined roles using their names


role = role.toEscapedModel();

// remaing code....
// remaing code....
// remaing code....


// Add result row

resultRows.add(row);
}
}
%>
thumbnail
Mani kandan, modificado hace 12 años.

RE: How to hide default roles for other users?

Expert Mensajes: 492 Fecha de incorporación: 15/09/10 Mensajes recientes
Hmm great its working fine.. Thanks a lot
Oliver Bayer, modificado hace 12 años.

RE: How to hide default roles for other users?

Liferay Master Mensajes: 894 Fecha de incorporación: 18/02/09 Mensajes recientes
Hi Mani,

Mani kandan:
I know it will do by the help of hook. But i dont know what code should i use for that ?

Sandeep and I have tried to answer it with some code snippets in your other thread emoticon.

Greets Oli
thumbnail
Mani kandan, modificado hace 12 años.

RE: How to hide default roles for other users?

Expert Mensajes: 492 Fecha de incorporación: 15/09/10 Mensajes recientes
Thanks Oliver,

I found another easiest solution...

Includes following code,


			if( OmniadminUtil.isOmniadmin(user.getUserId())||
			(!name.equals(RoleConstants.ADMINISTRATOR) 
			&amp;&amp; !name.equals(RoleConstants.COMMUNITY_ADMINISTRATOR)
			&amp;&amp; !name.equals(RoleConstants.COMMUNITY_OWNER) 
			&amp;&amp; !name.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR) 
			&amp;&amp; !name.equals(RoleConstants.ORGANIZATION_OWNER) 
			&amp;&amp; !name.equals(RoleConstants.ORGANIZATION_MEMBER) 
			&amp;&amp; !name.equals(RoleConstants.COMMUNITY_MEMBER) 
			&amp;&amp; !name.equals(RoleConstants.COMMUNITY_OWNER) 
			&amp;&amp; !name.equals(RoleConstants.ORGANIZATION_OWNER)
			&amp;&amp; !name.equals(RoleConstants.OWNER)
			&amp;&amp; !name.equals(RoleConstants.OWNER)
			&amp;&amp; !name.equals(RoleConstants.POWER_USER)
			&amp;&amp; !name.equals(RoleConstants.USER)
			&amp;&amp; !name.equals(RoleConstants.GUEST))){
				
			}
Oliver Bayer, modificado hace 12 años.

RE: How to hide default roles for other users?

Liferay Master Mensajes: 894 Fecha de incorporación: 18/02/09 Mensajes recientes
Hi Mani,

this is nearly the way I tried to suggest emoticon (only without iterating and using a for loop) with the mentionied pseudo code in the other thread. Thanks for sharing the code for others. I'm glad to hear you've got it to work.

Greets Oli
thumbnail
Mani kandan, modificado hace 12 años.

RE: How to hide default roles for other users?

Expert Mensajes: 492 Fecha de incorporación: 15/09/10 Mensajes recientes
Hi Oliver,
Thanks for guiding me and gave some idea.