Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Dave Weitzel
How do you hide control panel themes from users?
18. August 2011 07:09
Antwort

Dave Weitzel

Rang: Regular Member

Nachrichten: 169

Eintrittsdatum: 18. November 2009

Neue Beiträge

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. August 2011 02:47
Antwort

Pasi Kössi

Rang: New Member

Nachrichten: 1

Eintrittsdatum: 3. Mai 2011

Neue Beiträge

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. September 2011 04:48
Antwort

William Gosse

Rang: Regular Member

Nachrichten: 108

Eintrittsdatum: 4. Juli 2010

Neue Beiträge

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. Juli 2012 00:06
Antwort

Paul Butenko

Rang: Junior Member

Nachrichten: 38

Eintrittsdatum: 1. Juli 2010

Neue Beiträge

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