Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Dave Weitzel
How do you hide control panel themes from users?
18 de Agosto de 2011 07:09
Resposta

Dave Weitzel

Ranking: Regular Member

Mensagens: 204

Data de entrada: 18 de Novembro de 2009

Mensagens recentes

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 02:47
Resposta

Pasi Kössi

Ranking: New Member

Mensagens: 1

Data de entrada: 3 de Maio de 2011

Mensagens recentes

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 Setembro de 2011 04:48
Resposta

William Gosse

Ranking: Expert

Mensagens: 277

Data de entrada: 4 de Julho de 2010

Mensagens recentes

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 Julho de 2012 00:06
Resposta

Paul Butenko

Ranking: Junior Member

Mensagens: 38

Data de entrada: 1 de Julho de 2010

Mensagens recentes

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