public boolean filterEditableGroupKeys(UserRequest ureq, List<Long> groupKeys) { if (ureq.getUserSession().getRoles().isOLATAdmin() || ureq.getUserSession().getRoles().isGroupManager()) { return false; } int countBefore = groupKeys.size(); for (BGTableItem item : getObjects()) { Long groupKey = item.getBusinessGroupKey(); if (groupKeys.contains(groupKey)) { BusinessGroupMembership membership = item.getMembership(); if (membership == null || !membership.isOwner()) { groupKeys.remove(groupKey); } } } return groupKeys.size() != countBefore; }
public Object getValueAt(BGTableItem wrapped, int col) { switch (Cols.values()[col]) { case name: return wrapped; case description: String description = wrapped.getBusinessGroupDescription(); description = FilterFactory.getHtmlTagsFilter().filter(description); description = Formatter.truncate(description, 256); return description; case allowLeave: { Boolean allowed = wrapped.getAllowLeave(); if (allowed != null && allowed.booleanValue()) { // check managed groups if (BusinessGroupManagedFlag.isManaged( wrapped.getManagedFlags(), BusinessGroupManagedFlag.membersmanagement)) { return Boolean.FALSE; } } return allowed; } case allowDelete: { Boolean allowed = wrapped.getAllowDelete(); if (allowed != null && allowed.booleanValue()) { // check managed groups if (BusinessGroupManagedFlag.isManaged( wrapped.getManagedFlags(), BusinessGroupManagedFlag.delete)) { return Boolean.FALSE; } } return allowed; } case resources: return wrapped; case accessControl: return new Boolean(wrapped.isAccessControl()); case accessControlLaunch: return wrapped.getAccessLink(); case accessTypes: return wrapped.getAccessTypes(); case mark: return wrapped.getMarkLink(); case lastUsage: return wrapped.getBusinessGroupLastUsage(); case role: return wrapped.getMembership(); case firstTime: { BusinessGroupMembership membership = wrapped.getMembership(); return membership == null ? null : membership.getCreationDate(); } case lastTime: { BusinessGroupMembership membership = wrapped.getMembership(); return membership == null ? null : membership.getLastModified(); } case key: return wrapped.getBusinessGroupKey(); case freePlaces: { Integer maxParticipants = wrapped.getMaxParticipants(); if (maxParticipants != null && maxParticipants.intValue() >= 0) { long free = maxParticipants - (wrapped.getNumOfParticipants() + wrapped.getNumOfPendings()); return new GroupNumber(free); } return GroupNumber.INFINITE; } case participantsCount: { long count = wrapped.getNumOfParticipants() + wrapped.getNumOfPendings(); return count < 0 ? GroupNumber.ZERO : new GroupNumber(count); } case tutorsCount: { long count = wrapped.getNumOfOwners(); return count < 0 ? GroupNumber.ZERO : new GroupNumber(count); } case waitingListCount: { if (wrapped.isWaitingListEnabled()) { long count = wrapped.getNumWaiting(); return count < 0 ? GroupNumber.ZERO : new GroupNumber(count); } return GroupNumber.NONE; } case wrapper: return wrapped; case externalId: return wrapped.getBusinessGroupExternalId(); case unlink: { boolean managed = BusinessGroupManagedFlag.isManaged( wrapped.getManagedFlags(), BusinessGroupManagedFlag.resources); return managed ? Boolean.FALSE : Boolean.TRUE; } default: return "ERROR"; } }