Fórum

How do you hide control panel themes from users?

thumbnail
Dave Weitzel, modificado 12 Anos atrás.

How do you hide control panel themes from users?

Regular Member Postagens: 208 Data de Entrada: 18/11/09 Postagens 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, modificado 12 Anos atrás.

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

New Member Mensagem: 1 Data de Entrada: 03/05/11 Postagens 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
thumbnail
Bill Gosse, modificado 12 Anos atrás.

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

Liferay Master Postagens: 533 Data de Entrada: 04/07/10 Postagens Recentes
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, modificado 11 Anos atrás.

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

Junior Member Postagens: 38 Data de Entrada: 02/07/10 Postagens 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:
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