Author: julien_viet
Date: 2010-02-15 04:30:38 -0500 (Mon, 15 Feb 2010)
New Revision: 1681
Modified:
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java
portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/portlet.xml
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl
Log:
GTNPORTAL-644 : Use page edit permission as dashboard editability
Modified:
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java
===================================================================
---
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java 2010-02-15
09:12:44 UTC (rev 1680)
+++
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java 2010-02-15
09:30:38 UTC (rev 1681)
@@ -19,7 +19,13 @@
package org.exoplatform.dashboard.webui.component;
+import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.webui.container.UIContainer;
+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.workspace.UIPortalApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -31,10 +37,6 @@
@ComponentConfig(lifecycle = UIApplicationLifecycle.class, template =
"app:/groovy/dashboard/webui/component/UIDashboardPortlet.gtmpl", events = {})
public class UIDashboardPortlet extends UIPortletApplication implements DashboardParent
{
- private boolean isPrivate;
-
- private String owner;
-
public UIDashboardPortlet() throws Exception
{
PortletRequestContext context =
(PortletRequestContext)WebuiRequestContext.getCurrentInstance();
@@ -48,9 +50,6 @@
String aggregatorId = pref.getValue("aggregatorId",
"rssAggregator");
dashboard.setAggregatorId(aggregatorId);
-
- isPrivate = pref.getValue(ISPRIVATE, "0").equals(1);
- owner = pref.getValue(OWNER, null);
}
public int getNumberOfCols()
@@ -59,36 +58,28 @@
return dbCont.getChild(UIContainer.class).getChildren().size();
}
+ /**
+ * The implementation returns true if the current user has edit permission on the page
owning the dashboard
+ * portlet. Later it will be implemented with a finer granilarity.
+ */
public boolean canEdit()
{
PortletRequestContext context =
(PortletRequestContext)WebuiRequestContext.getCurrentInstance();
- String accessUser = context.getRemoteUser();
- if (accessUser == null || accessUser.equals(""))
- {
- return false;
- }
- if ("__CURRENT_USER__".equals(owner))
- {
- return true;
- }
- if (isPrivate)
- {
- if (accessUser.equals(owner))
- {
- return true;
- }
- }
- return false;
+ PortalRequestContext prc =
(PortalRequestContext)context.getParentAppRequestContext();
+ UIPortalApplication portalApp = (UIPortalApplication)prc.getUIApplication();
+ UIPortal portal = portalApp.getShowedUIPortal();
+ UIPageBody body = portal.findFirstComponentOfType(UIPageBody.class);
+ UIPage page = body.findFirstComponentOfType(UIPage.class);
+ UserACL userACL = portal.getApplicationComponent(UserACL.class);
+ return userACL.hasPermission(page.getEditPermission());
}
+ /**
+ * For now returns null.
+ */
public String getDashboardOwner()
{
- if ("__CURRENT_USER__".equals(owner))
- {
- PortletRequestContext context =
(PortletRequestContext)WebuiRequestContext.getCurrentInstance();
- return context.getRemoteUser();
- }
- return owner;
+ return null;
}
}
Modified: portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/portlet.xml 2010-02-15 09:12:44
UTC (rev 1680)
+++ portal/trunk/portlet/dashboard/src/main/webapp/WEB-INF/portlet.xml 2010-02-15 09:30:38
UTC (rev 1681)
@@ -45,14 +45,6 @@
<keywords>Integration</keywords>
</portlet-info>
<portlet-preferences>
- <preference>
- <name>isPrivate</name>
- <value>1</value>
- </preference>
- <preference>
- <name>owner</name>
- <value>__CURRENT_USER__</value>
- </preference>
<preference>
<name>template</name>
<value>three-columns</value>
Modified: portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl 2010-02-15
09:12:44 UTC (rev 1680)
+++
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIPopupMessages.gtmpl 2010-02-15
09:30:38 UTC (rev 1681)
@@ -17,6 +17,7 @@
def errors = uicomponent.getErrors();
def warnings = uicomponent.getWarnings();
def infos = uicomponent.getInfos();
+
boolean printTab(List messages, String title, boolean isSelected) {
String cssClass = "NormalTab";
if(messages.size() == 0) cssClass = "DisabledTab";
@@ -73,6 +74,7 @@
println " </div>";
return isSelected;
}
+
%>
<div class="UIPopupWindow UIDragObject" id="$popupId"
style="width: 550px; display: none;">
<div class="ExoMessageDecorator">
Show replies by date