Foren

How do you hide control panel themes from users?

thumbnail
Dave Weitzel, geändert vor 12 Jahren.

How do you hide control panel themes from users?

Regular Member Beiträge: 208 Beitrittsdatum: 18.11.09 Neueste 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, geändert vor 12 Jahren.

RE: How do you hide control panel themes from users?

New Member Beitrag: 1 Beitrittsdatum: 03.05.11 Neueste 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
thumbnail
Bill Gosse, geändert vor 12 Jahren.

RE: How do you hide control panel themes from users?

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
I was able to disable the viewing of the control panel by certain users by writing an extension to the ServicePreAction:

package com.salesquest.portal.events;

import com.liferay.portal.events.ServicePreAction;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.User;
import com.liferay.portal.security.permission.PermissionChecker;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.salesquest.portal.utils.SQPortalUtils;

public class SQServicePreAction extends ServicePreAction {

	@Override
	protected boolean isViewableGroup(User user, long groupId,
			boolean privateLayout, long layoutId,
			PermissionChecker permissionChecker) throws PortalException,
			SystemException {
		boolean isViewable = super.isViewableGroup(user, groupId,
				privateLayout, layoutId, permissionChecker);

		if (isViewable) {
			Group group = GroupLocalServiceUtil.getGroup(groupId);
			
		    if (group.isControlPanel())
		    {
				long companyId = group.getCompanyId();
				long userId = user.getUserId();

				if (SQPortalUtils.isUserAdminUser(companyId, userId))
					isViewable = true;
				else
					isViewable = !SQPortalUtils.isUserEnterpriseUser(userId);
		    }
		}

		return isViewable;
	}
}
Paul Butenko, geändert vor 11 Jahren.

RE: How do you hide control panel themes from users?

Junior Member Beiträge: 38 Beitrittsdatum: 02.07.10 Neueste 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:
public void run(HttpServletRequest request,
      HttpServletResponse response) throws ActionException {
 try {
 
   ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
   if (GroupLocalServiceUtil.getGroup(themeDisplay.getLayout().getGroupId()).isControlPanel()) {
 
  User currentUser = UserServiceUtil.getUserById(themeDisplay.getUserId());
  if (!RoleServiceUtil.hasUserRole(currentUser.getUserId(),
           currentUser.getCompanyId(),
           "administrator",
           true)) {
    throw new PrincipalException("User " + request.getRemoteUser()
     + " can't access the control panel.");
  }
   
   }
 } catch (Exception ex) {
   throw new ActionException(ex);
 }
  }



You can check complete example here