IDEMPIERE-5185 : Add RoleType in context (#1173)

This commit is contained in:
Nicolas Micoud 2022-02-12 07:20:52 +01:00 committed by GitHub
parent 2238f39916
commit 08ce41253b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -84,6 +84,7 @@ public final class Env
public static final String AD_PRINTTABLEFORMAT_ID = "#AD_PrintTableFormat_ID";
public static final String AD_ROLE_ID = "#AD_Role_ID";
public static final String AD_ROLE_NAME = "#AD_Role_Name";
public static final String AD_ROLE_TYPE = "#AD_Role_Type";
public static final String AD_SESSION_ID = "#AD_Session_ID";
public static final String AD_USER_ID = "#AD_User_ID";
public static final String AD_USER_NAME = "#AD_User_Name";

View File

@ -469,7 +469,7 @@ public class Login
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
KeyNamePair[] retValue = null;
String sql = "SELECT DISTINCT r.UserLevel, r.ConnectionProfile, " // 1/2
+ " c.AD_Client_ID,c.Name " // 3/4
+ " c.AD_Client_ID,c.Name,r.RoleType " // 3/4/5
+ "FROM AD_Role r"
+ " INNER JOIN AD_Client c ON (r.AD_Client_ID=c.AD_Client_ID) "
+ "WHERE r.AD_Role_ID=?" // #1
@ -493,6 +493,7 @@ public class Login
// Role Info
Env.setContext(m_ctx, Env.AD_ROLE_ID, role.getKey());
Env.setContext(m_ctx, Env.AD_ROLE_NAME, role.getName());
Env.setContext(m_ctx, Env.AD_ROLE_TYPE, rs.getString("RoleType"));
Ini.setProperty(Ini.P_ROLE, role.getName());
// User Level
Env.setContext(m_ctx, Env.USER_LEVEL, rs.getString(1)); // Format 'SCO'
@ -546,7 +547,7 @@ public class Login
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
KeyNamePair[] retValue = null;
//
String sql = " SELECT DISTINCT r.UserLevel, r.ConnectionProfile,o.AD_Org_ID,o.Name,o.IsSummary "
String sql = " SELECT DISTINCT r.UserLevel, r.ConnectionProfile,o.AD_Org_ID,o.Name,o.IsSummary,r.RoleType "
+" FROM AD_Org o"
+" INNER JOIN AD_Role r on (r.AD_Role_ID=?)"
+" INNER JOIN AD_Client c on (c.AD_Client_ID=?)"
@ -579,6 +580,7 @@ public class Login
// Role Info
Env.setContext(m_ctx, Env.AD_ROLE_ID, rol.getKey());
Env.setContext(m_ctx, Env.AD_ROLE_NAME, rol.getName());
Env.setContext(m_ctx, Env.AD_ROLE_TYPE, rs.getString("RoleType"));
Ini.setProperty(Ini.P_ROLE, rol.getName());
// User Level
Env.setContext(m_ctx, Env.USER_LEVEL, rs.getString(1)); // Format 'SCO'

View File

@ -590,6 +590,7 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
Env.setContext(properties, Env.AD_USER_NAME, Env.getContext(Env.getCtx(), Env.AD_USER_NAME));
Env.setContext(properties, Env.AD_ROLE_ID, Env.getAD_Role_ID(Env.getCtx()));
Env.setContext(properties, Env.AD_ROLE_NAME, Env.getContext(Env.getCtx(), Env.AD_ROLE_NAME));
Env.setContext(properties, Env.AD_ROLE_TYPE, Env.getContext(Env.getCtx(), Env.AD_ROLE_TYPE));
Env.setContext(properties, Env.USER_LEVEL, Env.getContext(Env.getCtx(), Env.USER_LEVEL));
Env.setContext(properties, Env.AD_ORG_NAME, Env.getContext(Env.getCtx(), Env.AD_ORG_NAME));
Env.setContext(properties, Env.M_WAREHOUSE_ID, Env.getContext(Env.getCtx(), Env.M_WAREHOUSE_ID));