Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Dave Weitzel
How do you hide control panel themes from users?
18 de agosto de 2011 7:09
Respuesta

Dave Weitzel

Ranking: Regular Member

Mensajes: 194

Fecha de incorporación: 18 de noviembre de 2009

Mensajes recientes

We have a new control panel theme and have it deployed as such through the portal>settings> dialogue and in a property for start up.

BUT the theme still shows up in the available themes for regular pages, I cannot see how this is done for the standard Liferay control panel theme.

Can anyone point me to the right setting?
Pasi Kössi
RE: How do you hide control panel themes from users?
19 de agosto de 2011 2:47
Respuesta

Pasi Kössi

Ranking: New Member

Mensajes: 1

Fecha de incorporación: 3 de mayo de 2011

Mensajes recientes

The functionality to hide the standard Control Panel theme seems to be hard coded in Java inside the ThemeService. You could do the same
for your own custom theme by hooking the service, or just hooking the jsp that shows the themes (/html/portlet/communities/edit_pages_look_and_feel.jsp).

PK
William Gosse
RE: How do you hide control panel themes from users?
20 de septiembre de 2011 4:48
Respuesta

William Gosse

Ranking: Regular Member

Mensajes: 202

Fecha de incorporación: 4 de julio de 2010

Mensajes recientes

I was able to disable the viewing of the control panel by certain users by writing an extension to the ServicePreAction:
 1
 2package com.salesquest.portal.events;
 3
 4import com.liferay.portal.events.ServicePreAction;
 5import com.liferay.portal.kernel.exception.PortalException;
 6import com.liferay.portal.kernel.exception.SystemException;
 7import com.liferay.portal.model.Group;
 8import com.liferay.portal.model.User;
 9import com.liferay.portal.security.permission.PermissionChecker;
10import com.liferay.portal.service.GroupLocalServiceUtil;
11import com.salesquest.portal.utils.SQPortalUtils;
12
13public class SQServicePreAction extends ServicePreAction {
14
15    @Override
16    protected boolean isViewableGroup(User user, long groupId,
17            boolean privateLayout, long layoutId,
18            PermissionChecker permissionChecker) throws PortalException,
19            SystemException {
20        boolean isViewable = super.isViewableGroup(user, groupId,
21                privateLayout, layoutId, permissionChecker);
22
23        if (isViewable) {
24            Group group = GroupLocalServiceUtil.getGroup(groupId);
25            
26            if (group.isControlPanel())
27            {
28                long companyId = group.getCompanyId();
29                long userId = user.getUserId();
30
31                if (SQPortalUtils.isUserAdminUser(companyId, userId))
32                    isViewable = true;
33                else
34                    isViewable = !SQPortalUtils.isUserEnterpriseUser(userId);
35            }
36        }
37
38        return isViewable;
39    }
40}
Paul Butenko
RE: How do you hide control panel themes from users?
13 de julio de 2012 0:06
Respuesta

Paul Butenko

Ranking: Junior Member

Mensajes: 38

Fecha de incorporación: 1 de julio de 2010

Mensajes recientes

Hi,
For liferay 6.1 you can hide liferays dockbar (control panel) by canging into portal_noranl.vm:
#if ($is_signed_in) to #if (($is_signed_in) && $permissionChecker.isCompanyAdmin($company_id))
To totally restrict access for non admin users hook can be used:
add portal.properties with property servlet.service.events.pre=my.event.portal.ControlPanelAccessPreAction
and in class add next method:
 1public void run(HttpServletRequest request,
 2      HttpServletResponse response) throws ActionException {
 3 try {
 4
 5   ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
 6   if (GroupLocalServiceUtil.getGroup(themeDisplay.getLayout().getGroupId()).isControlPanel()) {
 7
 8  User currentUser = UserServiceUtil.getUserById(themeDisplay.getUserId());
 9  if (!RoleServiceUtil.hasUserRole(currentUser.getUserId(),
10           currentUser.getCompanyId(),
11           "administrator",
12           true)) {
13    throw new PrincipalException("User " + request.getRemoteUser()
14     + " can't access the control panel.");
15  }
16   
17   }
18 } catch (Exception ex) {
19   throw new ActionException(ex);
20 }
21  }



You can check complete example here