留言板

How do you hide control panel themes from users?

thumbnail
Dave Weitzel,修改在12 年前。

How do you hide control panel themes from users?

Regular Member 帖子: 208 加入日期: 09-11-18 最近的帖子
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,修改在12 年前。

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

New Member 发布: 1 加入日期: 11-5-3 最近的帖子
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,修改在12 年前。

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

Liferay Master 帖子: 533 加入日期: 10-7-4 最近的帖子
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,修改在11 年前。

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

Junior Member 帖子: 38 加入日期: 10-7-2 最近的帖子
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