Fórum

Make "Toggle Edit Controls" unchecked for all users except admini

Sudarshan Chakrabarty, modificado 15 Anos atrás.

Make "Toggle Edit Controls" unchecked for all users except admini

New Member Postagens: 3 Data de Entrada: 27/02/09 Postagens Recentes
Hi,

Can I make the "Toggle Edit Controls" (which comes up on the Welcome panel) checkbox unchecked by default for all users except administrator so that only the administrator can see the configuration\look and feel\Close buttons?



I looked at the themes\$theme_name\templates\dock.vm which has the following code:

#if ($show_toggle_controls)
<li class="toggle-controls">
<a href="$toggle_controls_url">$toggle_controls_text</a>
</li>
#end

How do I check for if the user is admin or not before checking/unchecking this control or is there a different way to do that?

Or if there is some other way where I can make the Configuration\Look and feel\Close buttons invisible for all users( Including Power Users too) except administrator?

Thanks in advance.

Regards,
Sudarshan
thumbnail
Amos Fong, modificado 15 Anos atrás.

RE: Make "Toggle Edit Controls" unchecked for all users except ad

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
Hey Sudarshan,

You can check for admin role with something like:

#set ($userService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($adminRole = $roleService.getRole($company.getCompanyId(), "Administrator"))

#if ($userService.hasRoleUser($adminRole.getRoleId(), $user.getUserId()))
    [toggle stuff]
#end
Sudarshan Chakrabarty, modificado 15 Anos atrás.

RE: Make "Toggle Edit Controls" unchecked for all users except ad

New Member Postagens: 3 Data de Entrada: 27/02/09 Postagens Recentes
Thanks a lot Amos.
Sorry for the late reply, but I had got a different solution, though your solution looks far more graceful :-). Will try that out.
thumbnail
Hugo Alvarado, modificado 14 Anos atrás.

RE: Make "Toggle Edit Controls" unchecked for all users except ad

New Member Postagens: 11 Data de Entrada: 23/03/09 Postagens Recentes
Hi Sudarshan,

I'm facing the same problem and I was wondering if you can share your solution or some thoughts about it?

Thank you in advanced.
thumbnail
Sebastián Gurin, modificado 12 Anos atrás.

RE: Make "Toggle Edit Controls" unchecked for all users except ad

Junior Member Postagens: 75 Data de Entrada: 13/06/07 Postagens Recentes
Thank you very much for this Amos! Thanks to your example now I can call portal service classes from theme templates, very usefull. However, your example is incomplete. Here is my sollution, on my theme's dock.vm file:

<ul class="lfr-dock-list">
#if ($show_home)
<li class="home">
<a href="$home_url" title="$home_text">&nbsp;</a><span class="docseparator">|</span>
</li>
#end
......



##show toggle edit controls checbox only if user is admin:

#set ($userService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($roleService = $serviceLocator.findService("com.liferay.portal.service.RoleLocalService"))
#set ($adminRole = $roleService.getRole($company.getCompanyId(), "Administrator"))
#set ($userIsAdmin = $userService.hasRoleUser($adminRole.getRoleId(), $user.getUserId()))

#if ($userIsAdmin)
<li class="toggle-controls">
<a href="$toggle_controls_url" title="$toggle_controls_text">&nbsp;</a>
</li>
#end
dola dola, modificado 11 Anos atrás.

RE: Make "Toggle Edit Controls" unchecked for all users except ad

New Member Postagens: 7 Data de Entrada: 29/12/11 Postagens Recentes
can u tell me the path of dock.vm ?
i`m using liferay 6.1 and cannot find this file .
thanks .
thumbnail
Hitoshi Ozawa, modificado 11 Anos atrás.

RE: Make "Toggle Edit Controls" unchecked for all users except ad

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
You really should be creating a new thread instead of adding your question to an old thread because files have changed since this thread was created.

The file to modify is now. If you don't know how to modify this file, create a new thread instead of replying to this one.
webapps\ROOT\html\portlet\dockbar\view.jsp