Author: hoang_to
Date: 2010-01-13 22:57:13 -0500 (Wed, 13 Jan 2010)
New Revision: 1273
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIAdminToolbarPortlet.gtmpl
Log:
GTNPORTAL-466: Fix errors in checking permission
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java 2010-01-14
02:56:10 UTC (rev 1272)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java 2010-01-14
03:57:13 UTC (rev 1273)
@@ -248,6 +248,31 @@
{
return hasEditPermission(getIdentity(), pconfig);
}
+
+ /**
+ * This method is equivalent to
<code>hasEditPermission(PortalConfig)</code>. That allows us
+ * to check edit permission on a UIPortal, without converting UIPortal into
PortalConfig via
+ * PortalDataMapper.
+ *
+ * @param ownerType
+ * @param ownerId
+ * @param editPermExpression
+ * @return
+ */
+ public boolean hasEditPermissionOnPortal(String ownerType, String ownerId, String
editPermExpression)
+ {
+ Identity identity = this.getIdentity();
+ if(superUser_.equals(identity.getUserId()))
+ {
+ return true;
+ }
+
+ if(PortalConfig.USER_TYPE.equals(ownerType)){
+ return identity.getUserId().equals(ownerId);
+ }
+
+ return hasPermission(identity, editPermExpression);
+ }
public boolean hasCreatePortalPermission()
{
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java 2010-01-14
02:56:10 UTC (rev 1272)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java 2010-01-14
03:57:13 UTC (rev 1273)
@@ -21,8 +21,10 @@
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.webui.page.UIPage;
import org.exoplatform.portal.webui.page.UIPageBody;
+import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
@@ -58,8 +60,8 @@
{
// A user could view the toolbar portlet iff he/she has edit permission
// either on
- // 'active' page or 'active' portal
- if (hasEditPermissionOnNavigation() || hasEditPermissionOnPage())
+ // 'active' page, 'active' portal or 'active' navigation
+ if (hasEditPermissionOnNavigation() || hasEditPermissionOnPage() ||
hasEditPermissionOnPortal())
{
super.processRender(app, context);
}
@@ -79,6 +81,14 @@
return userACL.hasEditPermission(selectedNavigation);
}
}
+
+ private boolean hasEditPermissionOnPortal() throws Exception
+ {
+ UIPortalApplication portalApp = Util.getUIPortalApplication();
+ UIPortal currentUIPortal =
portalApp.<UIWorkingWorkspace>findComponentById(UIPortalApplication.UI_WORKING_WS_ID).findFirstComponentOfType(UIPortal.class);
+ UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
+ return userACL.hasEditPermissionOnPortal(currentUIPortal.getOwnerType(),
currentUIPortal.getOwner(), currentUIPortal.getEditPermission());
+ }
private boolean hasEditPermissionOnPage() throws Exception
{
Modified:
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIAdminToolbarPortlet.gtmpl
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIAdminToolbarPortlet.gtmpl 2010-01-14
02:56:10 UTC (rev 1272)
+++
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIAdminToolbarPortlet.gtmpl 2010-01-14
03:57:13 UTC (rev 1273)
@@ -22,6 +22,7 @@
boolean userCouldEditNavigation = uicomponent.hasEditPermissionOnNavigation();
boolean userCouldEditPage = uicomponent.hasEditPermissionOnPage();
+ boolean userCouldEditPortal = uicomponent.hasEditPermissionOnPortal();
PageNavigation selectedNav = uicomponent.getSelectedNavigation();
if (selectedNav != null) {
@@ -50,7 +51,7 @@
</div>
<% } %>
- <% if(userCouldEditNavigation){ %>
+ <% if(userCouldEditPortal){ %>
<div class="MenuItem">
<a
href="javascript:ajaxGet(eXo.env.server.createPortalURL('UIWorkingWorkspace',
'EditInline', true))" title="" class="ItemIcon
EditSiteIcon">$editSiteLayout</a>
</div>
Show replies by date