Forums de discussion

if(administrator)

Robin S., modifié il y a 15 années.

if(administrator)

Regular Member Publications: 116 Date d'inscription: 16/09/08 Publications récentes
Hi folks,

is there any way to "ask" liferay whether there is an administrator logged in or not in the velocity files?
so that i can add items, for example the liferay dock, only when an admin is logged in to liferay.

regards
thumbnail
Tobias Amon, modifié il y a 15 années.

RE: if(administrator)

Liferay Master Publications: 546 Date d'inscription: 08/08/07 Publications récentes
Hi,

do you mean, you want to know whether the current user is an administrator or not?

kind regards
Tobias
Robin S., modifié il y a 15 années.

RE: if(administrator)

Regular Member Publications: 116 Date d'inscription: 16/09/08 Publications récentes
Hi Tobias,

exactly

regards
thumbnail
Tobias Amon, modifié il y a 15 années.

RE: if(administrator)

Liferay Master Publications: 546 Date d'inscription: 08/08/07 Publications récentes
Hi,

maybe you don't need to know if your user is an admin... you can simply configure new resource-actions.
Have a look here for details.

kind regards
Tobias
Robin S., modifié il y a 15 années.

RE: if(administrator)

Regular Member Publications: 116 Date d'inscription: 16/09/08 Publications récentes
Ok, i will try it.
Thanks.

Regards
Robin S., modifié il y a 15 années.

RE: if(administrator)

Regular Member Publications: 116 Date d'inscription: 16/09/08 Publications récentes
Hi,

I have now found a very easy way to "ask" liferay if the current user is an administrator (or any other role) in the velocity template of the themes.
simply type

#set ($roleLocalService = $serviceLocator.findService("com.liferay.portal.service.RoleLocalService"))

#if ($roleLocalService.hasUserRole($user.getUserId(), COMPANY_ID , "ROLE_NAME", true))
...
#end

just insert your company id and the name of the role you want to check.


regards