Author: hoang_to
Date: 2010-05-06 04:11:21 -0400 (Thu, 06 May 2010)
New Revision: 2993
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/navigation/webui/component/UIGroupNavigationManagement.gtmpl
Log:
GTNPORTAL-1151: User could not add new navigation even though he is manager of group
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2010-05-06
07:51:36 UTC (rev 2992)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2010-05-06
08:11:21 UTC (rev 2993)
@@ -36,6 +36,7 @@
import org.exoplatform.portal.webui.workspace.UIMaskWorkspace;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
+import org.exoplatform.services.organization.OrganizationService;
import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -52,6 +53,7 @@
import org.exoplatform.webui.event.Event.Phase;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.UUID;
@@ -168,6 +170,50 @@
selectedNavigation = navigation;
}
+ /**
+ * User has right to add navigation to a group in below cases
+ *
+ * 1. He/She is member of admin groups
+ *
+ * 2. He/She is manager of the group
+ *
+ * @param pcontext
+ * @return
+ */
+ private boolean userHasRightToAddNavigation()
+ {
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ String remoteUser = pcontext.getRemoteUser();
+ if (remoteUser == null)
+ {
+ return false;
+ }
+
+ UserACL userACL = this.getApplicationComponent(UserACL.class);
+ if (userACL.isUserInGroup(userACL.getAdminGroups()))
+ {
+ return true;
+ }
+
+ OrganizationService orgService =
this.getApplicationComponent(OrganizationService.class);
+ try
+ {
+ Collection<?> groups =
orgService.getGroupHandler().findGroupByMembership(remoteUser, UserACL.MANAGER);
+ if (groups != null && groups.size() > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ }
+
static public class EditNavigationActionListener extends
EventListener<UIGroupNavigationManagement>
{
public void execute(Event<UIGroupNavigationManagement> event) throws
Exception
Modified:
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/navigation/webui/component/UIGroupNavigationManagement.gtmpl
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/navigation/webui/component/UIGroupNavigationManagement.gtmpl 2010-05-06
07:51:36 UTC (rev 2992)
+++
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/navigation/webui/component/UIGroupNavigationManagement.gtmpl 2010-05-06
08:11:21 UTC (rev 2993)
@@ -6,7 +6,7 @@
uicomponent.loadNavigations();
uicomponent.renderChild(UIVirtualList.class);
- if(uicomponent.getNavigations() != null && uicomponent.getNavigations().size()
> 0){ %>
+ if(uicomponent.userHasRightToAddNavigation()){ %>
<div class="UIAction">
<table class="ActionContainer">
Show replies by date