IDEMPIERE-1920 Restrict Copy Role

This commit is contained in:
Carlos Ruiz 2014-04-29 17:54:07 -05:00
parent 8ecad8bea8
commit 1c4f333dfc
3 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,19 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Apr 28, 2014 5:35:23 PM COT
-- Decrease AccessLevel For Security Related Processes
UPDATE AD_Process SET AccessLevel='6',Updated=TO_DATE('2014-04-28 17:35:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=50010
;
-- Apr 28, 2014 5:35:54 PM COT
UPDATE AD_Process SET AccessLevel='6',Updated=TO_DATE('2014-04-28 17:35:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=200008
;
-- Apr 29, 2014 5:47:13 PM COT
UPDATE AD_Process SET Help='Copy role access records from one role to another. The existing access records for the destination role will be deleted. This process can be executed just by advanced roles.',Updated=TO_DATE('2014-04-29 17:47:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=50010
;
SELECT register_migration_script('201404281824_IDEMPIERE-1920.sql') FROM dual
;

View File

@ -0,0 +1,16 @@
-- Apr 28, 2014 5:35:23 PM COT
-- Decrease AccessLevel For Security Related Processes
UPDATE AD_Process SET AccessLevel='6',Updated=TO_TIMESTAMP('2014-04-28 17:35:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=50010
;
-- Apr 28, 2014 5:35:54 PM COT
UPDATE AD_Process SET AccessLevel='6',Updated=TO_TIMESTAMP('2014-04-28 17:35:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=200008
;
-- Apr 29, 2014 5:47:13 PM COT
UPDATE AD_Process SET Help='Copy role access records from one role to another. The existing access records for the destination role will be deleted. This process can be executed just by advanced roles.',Updated=TO_TIMESTAMP('2014-04-29 17:47:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=50010
;
SELECT register_migration_script('201404281824_IDEMPIERE-1920.sql') FROM dual
;

View File

@ -21,9 +21,12 @@ package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.I_AD_Role_Included; import org.compiere.model.I_AD_Role_Included;
import org.compiere.model.MRole;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg;
/** /**
@ -72,6 +75,10 @@ public class CopyRole extends SvrProcess
*/ */
protected String doIt() throws Exception protected String doIt() throws Exception
{ {
if (! MRole.getDefault().isAccessAdvanced()) {
throw new AdempiereException(Msg.getMsg(getCtx(), "CannotAccessProcess", new Object[] {getProcessInfo().getAD_Process_ID(), MRole.getDefault().getName()}));
}
String[] tables = new String[] {"AD_Window_Access", "AD_Process_Access", "AD_Form_Access", String[] tables = new String[] {"AD_Window_Access", "AD_Process_Access", "AD_Form_Access",
"AD_Workflow_Access", "AD_Task_Access", "AD_Document_Action_Access", "AD_Workflow_Access", "AD_Task_Access", "AD_Document_Action_Access",
I_AD_Role_Included.Table_Name, I_AD_Role_Included.Table_Name,