回复 3# purple
输出当前用户在当前程序中所有角色的名称:
var roles=user.getRoles();
var currentApplicationid =getApplication();
var rtn="";
for(var it = roles.iterator();roles!=null && it.hasNext();){
var role = it.next();
if(currentApplicationid.equals(role.getApplicationid())){
rtn+=role.getName()+"|";
}
}
rtn;
判断当前用户在当前程序中是否拥有某角色的权限:
var roles = user.getRoles();
var rtn=false;
var currentApplicationid =getApplication();
for(var it = roles.iterator();roles!=null && it.hasNext();)
{
var role = it.next();
if(currentApplicationid.equals(role.getApplicationid()))
{
if(role.getName()=="行政助理" || role.getName()=="管理员")
{
rtn=true;
}
}
}
rtn; |