Attached Files | issue36931_Sol1.diff [^] (7,538 bytes) 2017-09-26 18:50 [Show Content] [Hide Content]diff --git a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-pick-and-execute-view-window.js.ftl b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-pick-and-execute-view-window.js.ftl
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-pick-and-execute-view-window.js.ftl
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-pick-and-execute-view-window.js.ftl
@@ -12,7 +12,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2016 Openbravo SLU
+ * All portions are Copyright (C) 2011-2017 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -27,7 +27,10 @@
isc.ClassFactory.defineClass('<#if !data.popup>processDefinition</#if>${data.windowClientClassName?js_string}', isc.OBParameterWindowView).addProperties({
processId: '${data.processId?js_string}',
actionHandler: '${data.actionHandler?js_string}',
- popup: ${data.popup?string},
+ popup: ${data.popup?string},
+ <#if !data.accessible>
+ hasAccess: false,
+ </#if>
<#if data.clientSideValidation??>
clientSideValidation: ${data.clientSideValidation?js_string},
</#if>
diff --git a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2012-2016 Openbravo SLU
+ * All portions are Copyright (C) 2012-2017 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -37,6 +37,8 @@
import org.openbravo.client.kernel.BaseTemplateComponent;
import org.openbravo.client.kernel.KernelConstants;
import org.openbravo.client.kernel.Template;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.security.EntityAccessChecker;
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
import org.openbravo.model.ad.domain.Validation;
@@ -158,6 +160,12 @@
return new ArrayList<org.openbravo.model.ad.domain.List>();
}
+ public boolean isAccessible() {
+ String userLevel = OBContext.getOBContext().getUserLevel();
+ int accessLevel = Integer.parseInt(process.getDataAccessLevel());
+ return EntityAccessChecker.hasCorrectAccessLevel(userLevel, accessLevel);
+ }
+
public boolean isReport() {
return ApplicationConstants.REPORT_UI_PATTERN.equals(process.getUIPattern());
}
diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-base-parameter-window-view.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-base-parameter-window-view.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-base-parameter-window-view.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-base-parameter-window-view.js
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2015-2016 Openbravo SLU
+ * All portions are Copyright (C) 2015-2017 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -44,6 +44,8 @@
baseParams: {},
formProps: {},
+ hasAccess: true,
+
// allows to calculate extra context info (ie. when invoking from menu)
additionalContextInfo: {},
@@ -56,6 +58,13 @@
// this flag can be used by Selenium to determine when defaults are set
this.defaultsAreSet = false;
+ if (!this.hasAccess) {
+ this.addMessageBar(view);
+ this.Super('initWidget', arguments);
+ this.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, OB.I18N.getLabel('AccessTableNoView'));
+ return;
+ }
+
buttonLayout = view.buildButtonLayout();
if (!this.popup) {
@@ -68,21 +77,7 @@
this.members.push(this.toolBarLayout);
}
- this.messageBar = isc.OBMessageBar.create({
- visibility: 'hidden',
- view: this,
- show: function () {
- var showMessageBar = true;
- this.Super('show', arguments);
- view.resized(showMessageBar);
- },
- hide: function () {
- var showMessageBar = false;
- this.Super('hide', arguments);
- view.resized(showMessageBar);
- }
- });
- this.members.push(this.messageBar);
+ this.addMessageBar(view);
newShowIf = function (item, value, form, values) {
var currentValues, originalShowIfValue = false,
@@ -234,6 +229,24 @@
});
},
+ addMessageBar: function (paramView) {
+ paramView.messageBar = isc.OBMessageBar.create({
+ visibility: 'hidden',
+ view: paramView,
+ show: function () {
+ var showMessageBar = true;
+ this.Super('show', arguments);
+ paramView.resized(showMessageBar);
+ },
+ hide: function () {
+ var showMessageBar = false;
+ this.Super('hide', arguments);
+ paramView.resized(showMessageBar);
+ }
+ });
+ paramView.members.push(this.messageBar);
+ },
+
/*
* Function that creates the layout with the buttons. Classes implementing OBBaseParameterWindowView
* have to override this function to add the needed buttons.
diff --git a/src-db/database/sourcedata/AD_MESSAGE.xml b/src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml
@@ -290,7 +290,7 @@
<!--124--> <MSGTEXT><![CDATA[With your current role and settings, you cannot view this information]]></MSGTEXT>
<!--124--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
<!--124--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--124--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--124--> <ISINCLUDEINI18N><![CDATA[Y]]></ISINCLUDEINI18N>
<!--124--></AD_MESSAGE>
<!--125--><AD_MESSAGE>
diff --git a/src/org/openbravo/dal/security/EntityAccessChecker.java b/src/org/openbravo/dal/security/EntityAccessChecker.java
--- a/src/org/openbravo/dal/security/EntityAccessChecker.java
+++ b/src/org/openbravo/dal/security/EntityAccessChecker.java
@@ -351,7 +351,7 @@
* the data access level defined in the table
* @return true if access is allowed, false otherwise
*/
- private boolean hasCorrectAccessLevel(String userLevel, int accessLevel) {
+ public static boolean hasCorrectAccessLevel(String userLevel, int accessLevel) {
// copied from HttpSecureAppServlet.
if (!OBContext.getOBContext().doAccessLevelCheck()) {
return true;
issue36931_Sol2.diff [^] (2,357 bytes) 2017-09-26 19:07 [Show Content] [Hide Content]diff --git a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ViewComponent.java b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ViewComponent.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ViewComponent.java
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ViewComponent.java
@@ -46,6 +46,7 @@
import org.openbravo.client.kernel.KernelConstants;
import org.openbravo.client.kernel.OBUserException;
import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.security.EntityAccessChecker;
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
import org.openbravo.erpCommon.obps.ActivationKey;
@@ -103,6 +104,8 @@
Process process = OBDal.getInstance().get(Process.class, processId);
if (process == null) {
throw new IllegalArgumentException("Not found process definition with ID " + processId);
+ } else if (!hasAccess(process)) {
+ throw new OBUserException("AccessTableNoView");
}
return generateProcess(process);
} else if (viewId.startsWith("attachment_")) {
@@ -116,6 +119,12 @@
}
}
+ private boolean hasAccess(Process process) {
+ String userLevel = OBContext.getOBContext().getUserLevel();
+ int accessLevel = Integer.parseInt(process.getDataAccessLevel());
+ return EntityAccessChecker.hasCorrectAccessLevel(userLevel, accessLevel);
+ }
+
protected String generateWindow(Window window) {
standardWindowComponent.setWindow(window);
standardWindowComponent.setParameters(getParameters());
diff --git a/src/org/openbravo/dal/security/EntityAccessChecker.java b/src/org/openbravo/dal/security/EntityAccessChecker.java
--- a/src/org/openbravo/dal/security/EntityAccessChecker.java
+++ b/src/org/openbravo/dal/security/EntityAccessChecker.java
@@ -351,7 +351,7 @@
* the data access level defined in the table
* @return true if access is allowed, false otherwise
*/
- private boolean hasCorrectAccessLevel(String userLevel, int accessLevel) {
+ public static boolean hasCorrectAccessLevel(String userLevel, int accessLevel) {
// copied from HttpSecureAppServlet.
if (!OBContext.getOBContext().doAccessLevelCheck()) {
return true;
issue36931_Sol3.diff [^] (5,505 bytes) 2017-09-28 17:37 [Show Content] [Hide Content]diff --git a/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java b/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java
@@ -32,6 +32,7 @@
import org.openbravo.client.application.ProcessAccess;
import org.openbravo.client.kernel.BaseActionHandler;
import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.security.EntityAccessChecker;
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
import org.openbravo.database.SessionInfo;
@@ -170,6 +171,13 @@
*
*/
public static boolean hasAccess(Process processDefinition, Map<String, Object> parameters) {
+ // Check Process Definition Access Level
+ String userLevel = OBContext.getOBContext().getUserLevel();
+ int accessLevel = Integer.parseInt(processDefinition.getDataAccessLevel());
+ if (!EntityAccessChecker.hasCorrectAccessLevel(userLevel, accessLevel)) {
+ return false;
+ }
+ // Check Process Definition Permission
String windowId = (String) parameters.get("windowId");
if (windowId != null && !"null".equals(windowId)) {
Window window = OBDal.getInstance().get(Window.class, windowId);
diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-base-parameter-window-view.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-base-parameter-window-view.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-base-parameter-window-view.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-base-parameter-window-view.js
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2015-2016 Openbravo SLU
+ * All portions are Copyright (C) 2015-2017 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -230,7 +230,11 @@
params.windowId = this.windowId;
OB.RemoteCallManager.call(this.defaultsActionHandler, context, params, function (rpcResponse, data, rpcRequest) {
- view.handleDefaults(data);
+ if (data && data.message && data.message.severity === isc.OBMessageBar.TYPE_ERROR) {
+ view.handleErrorState(data.message);
+ } else {
+ view.handleDefaults(data);
+ }
});
},
@@ -269,7 +273,6 @@
},
showProcessing: function (processing) {
- var i;
if (processing) {
if (this.theForm) {
this.theForm.hide();
@@ -277,15 +280,7 @@
if (this.popupButtons) {
this.popupButtons.hide();
}
-
- if (this.toolBarLayout) {
- for (i = 0; i < this.toolBarLayout.children.length; i++) {
- if (this.toolBarLayout.children[i].hide) {
- this.toolBarLayout.children[i].hide();
- }
- }
- }
-
+ this.hideToolBarLayoutChildren();
this.loading.show();
} else {
if (this.theForm) {
@@ -296,6 +291,17 @@
}
},
+ hideToolBarLayoutChildren: function () {
+ var i;
+ if (this.toolBarLayout) {
+ for (i = 0; i < this.toolBarLayout.children.length; i++) {
+ if (this.toolBarLayout.children[i].hide) {
+ this.toolBarLayout.children[i].hide();
+ }
+ }
+ }
+ },
+
// Checks params with readonly logic enabling or disabling them based on it
handleReadOnlyLogic: function () {
var form, fields, i, field, parentContext;
@@ -334,6 +340,28 @@
}
},
+ handleErrorState: function (message) {
+ // Disable the parameter view elements
+ this.disableFormItems();
+ if (this.theForm) {
+ this.theForm.disable();
+ }
+ // Hide the buttons (if any)
+ this.hideToolBarLayoutChildren();
+ if (this.popupButtons && this.popupButtons.hide) {
+ this.popupButtons.hide();
+ }
+ if (!message) {
+ return;
+ }
+ // Show the error message
+ if (message.title) {
+ this.messageBar.setMessage(message.severity, message.title, message.text);
+ } else {
+ this.messageBar.setMessage(message.severity, OB.I18N.getLabel('OBUIAPP_Error'), message.text);
+ }
+ },
+
handleDefaults: function (result) {
var i, field, def, defaults = result.defaults,
filterExpressions = result.filterExpressions,
diff --git a/src/org/openbravo/dal/security/EntityAccessChecker.java b/src/org/openbravo/dal/security/EntityAccessChecker.java
--- a/src/org/openbravo/dal/security/EntityAccessChecker.java
+++ b/src/org/openbravo/dal/security/EntityAccessChecker.java
@@ -351,7 +351,7 @@
* the data access level defined in the table
* @return true if access is allowed, false otherwise
*/
- private boolean hasCorrectAccessLevel(String userLevel, int accessLevel) {
+ public static boolean hasCorrectAccessLevel(String userLevel, int accessLevel) {
// copied from HttpSecureAppServlet.
if (!OBContext.getOBContext().doAccessLevelCheck()) {
return true;
|