Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Dave Weitzel
How do you hide control panel themes from users?
18 agosto 2011 7.09
Risposta

Dave Weitzel

Punteggio: Regular Member

Messaggi: 194

Data di Iscrizione: 18 novembre 2009

Messaggi recenti

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 agosto 2011 2.47
Risposta

Pasi Kössi

Punteggio: New Member

Messaggi: 1

Data di Iscrizione: 3 maggio 2011

Messaggi recenti

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 settembre 2011 4.48
Risposta

William Gosse

Punteggio: Regular Member

Messaggi: 202

Data di Iscrizione: 4 luglio 2010

Messaggi recenti

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 luglio 2012 0.06
Risposta

Paul Butenko

Punteggio: Junior Member

Messaggi: 38

Data di Iscrizione: 1 luglio 2010

Messaggi recenti

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