Example #1
0
  @Override
  public boolean canUserAccessProject(long userId, int projectId) {
    User u = accountMgr.getUser(userId);
    Project p = projectMgr.getProject(projectId);

    return u.isAdmin() || p.isUserMember(userId);
  }
Example #2
0
 @Override
 public long getCorporationListWithPagerNum(long userId) {
   User user = accountMgr.getUser(userId);
   if (user.isAdmin()) {
     return getCorporationListWithPagerNum();
   }
   return organizationDao.getCorporationListWithPagerNum(userId);
 }
Example #3
0
 @Override
 public boolean canUserAccessCorp(long userId, int corpId) {
   Corporation c = getCorporation(corpId);
   if (c == null) return false;
   if (c.getUserId() == userId) return true;
   User user = accountMgr.getUser(userId);
   if (user != null && user.isAdmin()) return true;
   return organizationDao.isUserInCorp(userId, corpId);
 }
Example #4
0
 private boolean canUserManageUserInCorp(long curUserId, long userId, int corpId) {
   User curUser = accountMgr.getUser(curUserId);
   if (curUser.isAdmin()) {
     return true;
   }
   int roleId = getUserRoleInCorp(curUserId, corpId);
   if (roleId >= 1 || roleId <= 2) {
     return true;
   }
   return false;
 }
Example #5
0
 @Override
 public List<Corporation> getCorporationListWithPager(long userId, int pageNum, int pageSize) {
   User user = accountMgr.getUser(userId);
   if (user.isAdmin()) {
     return getCorporationListWithPager(pageNum, pageSize);
   }
   List<Corporation> list = organizationDao.getCorporationListWithPager(userId, pageNum, pageSize);
   for (Corporation c : list) {
     long memberNum = organizationDao.getMemberNumOfCorporation(c.getId());
     c.setMemberNum(memberNum + 1); // +1 project creator
     c.setHasAccess(canUserManageCorp(userId, c.getId()));
     c.setCreatorName(accountMgr.getUser(c.getUserId()).getName());
   }
   return list;
 }
Example #6
0
 @Override
 public List<User> getUserLisOfCorp(int corpId) {
   List<User> list = organizationDao.getUserLisOfCorp(corpId);
   Corporation c = getCorporation(corpId);
   User u = accountMgr.getUser(c.getUserId());
   list.add(u);
   for (User user : list) {
     int roleId = getUserRoleInCorp(user.getId(), corpId);
     if (user.isAdmin()) {
       roleId = 1; // user is the RAP platform admin
     } else if (user.getId() == c.getUserId()) {
       roleId = 1; // user is the author
     }
     user.setRoleId(roleId);
   }
   return list;
 }