/** * @see org.projectforge.business.user.UserRightAccessCheck#hasSelectAccess(org.projectforge.framework.persistence.user.entities.PFUserDO, * java.lang.Object) */ @Override public boolean hasSelectAccess(final PFUserDO user, final TeamCalDO obj) { if (isOwner(user, obj) == true || accessChecker.isUserMemberOfAdminGroup(user) == true) { // User has full access to his own calendars. return true; } final Integer userId = user.getId(); if (hasFullAccess(obj, userId) == true || hasReadonlyAccess(obj, userId) == true || hasMinimalAccess(obj, userId) == true) { return true; } return false; }
public TeamEventRight(AccessChecker accessChecker) { super(accessChecker, UserRightId.PLUGIN_CALENDAR_EVENT, UserRightCategory.PLUGINS, UserRightValue.TRUE); teamCalRight = new TeamCalRight(accessChecker); }
private boolean hasAccess(final Integer[] groupIds, final Integer[] userIds, final Integer userId) { if (getUserGroupCache().isUserMemberOfAtLeastOneGroup(userId, groupIds) == true) { return true; } if (userIds == null) { return false; } for (final Integer id : userIds) { if (id == null) { continue; } if (id.equals(userId) == true) { return true; } } return false; }
/** * @param calendar * @param userId * @return {@link TeamCalAccessType#NONE}, {@link TeamCalAccessType#MINIMAL}, {@link TeamCalAccessType#READONLY} or * {@link TeamCalAccessType#FULL}. null will never be returned! */ public DataobjectAccessType getAccessType(final TeamCalDO calendar, final Integer userId) { if (calendar == null || userId == null) { return DataobjectAccessType.NONE; } if (hasFullAccess(calendar, userId) == true) { return DataobjectAccessType.FULL; } else if (hasReadonlyAccess(calendar, userId) == true) { return DataobjectAccessType.READONLY; } else if (hasMinimalAccess(calendar, userId) == true) { return DataobjectAccessType.MINIMAL; } return DataobjectAccessType.NONE; }
public boolean hasMinimalAccess(final TeamCalDO calendar, final Integer userId) { if (calendar == null || userId == null) { return false; } if (hasFullAccess(calendar, userId) == true || hasReadonlyAccess(calendar, userId) == true) { // User has full access or read-only access (which is more than minimal access). return false; } final Integer[] groupIds = StringHelper.splitToIntegers(calendar.getMinimalAccessGroupIds(), ","); final Integer[] userIds = StringHelper.splitToIntegers(calendar.getMinimalAccessUserIds(), ","); return hasAccess(groupIds, userIds, userId); }
/** * Owners of the given calendar and users with full and read-only access have update access to the given calendar: * obj.getCalendar(). * * @see org.projectforge.business.user.UserRightAccessCheck#hasHistoryAccess(org.projectforge.framework.persistence.user.entities.PFUserDO, * java.lang.Object) */ @Override public boolean hasHistoryAccess(final PFUserDO user, final TeamEventDO obj) { if (obj == null) { return true; } final TeamCalDO calendar = obj.getCalendar(); if (calendar == null) { return false; } if (ObjectUtils.equals(user.getId(), calendar.getOwnerId()) == true) { // User has full access to it's own calendars. return true; } final Integer userId = user.getId(); if (teamCalRight.hasFullAccess(calendar, userId) == true || teamCalRight.hasReadonlyAccess(calendar, userId) == true) { return true; } return false; }
final TeamCalRight right = new TeamCalRight(accessChecker); final PFUserDO user = ThreadLocalUserContext.getUser(); final TimeZone timeZone = ThreadLocalUserContext.getTimeZone(); title = teamEvent.getSubject(); if (right.hasMinimalAccess(eventDO.getCalendar(), user.getId()) == true) {
}, getString("plugins.teamcal.events")); addContentMenuEntry(menu); final TeamCalRight right = new TeamCalRight(accessChecker); if (isNew() == true || right.hasFullAccess(getData(), getUserId()) == true && getData().isExternalSubscription() == false) { menu = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Void>(ContentMenuEntryPanel.LINK_ID)
public boolean hasReadonlyAccess(final TeamCalDO calendar, final Integer userId) { if (calendar == null || userId == null) { return false; } if (hasFullAccess(calendar, userId) == true) { // User has full access (which is more than read-only access). return false; } final Integer[] groupIds = StringHelper.splitToIntegers(calendar.getReadonlyAccessGroupIds(), ","); final Integer[] userIds = StringHelper.splitToIntegers(calendar.getReadonlyAccessUserIds(), ","); return hasAccess(groupIds, userIds, userId); }
/** * Get ordered calendars (by title and id). * * @return All accessible calendars of the context user (as owner or with full, read-only or minimal access). */ public Collection<TeamCalDO> getAllFullAccessCalendars() { checkRefresh(); final Set<TeamCalDO> set = new TreeSet<TeamCalDO>(new TeamCalsComparator()); final PFUserDO loggedInUser = ThreadLocalUserContext.getUser(); for (final TeamCalDO cal : calendarMap.values()) { if (teamCalRight.hasFullAccess(cal, loggedInUser.getId()) == true && cal.isDeleted() == false) { set.add(cal); } } return set; }
public boolean hasFullAccess(final TeamCalDO calendar, final Integer userId) { if (calendar == null || userId == null) { return false; } if (isOwner(userId, calendar) == true) { return true; } final Integer[] groupIds = StringHelper.splitToIntegers(calendar.getFullAccessGroupIds(), ","); final Integer[] userIds = StringHelper.splitToIntegers(calendar.getFullAccessUserIds(), ","); return hasAccess(groupIds, userIds, userId); }
public boolean hasMinimalAccess(final TeamEventDO event, final Integer userId) { if (event.getCalendar() == null) { return true; } return teamCalRight.hasMinimalAccess(event.getCalendar(), userId); } }
final TeamCalRight right = new TeamCalRight(accessChecker); if (isNew() == true || right.hasUpdateAccess(getUser(), data, data) == true) { access = true;
/** * Owners and administrators are able to insert new calendars. * * @see org.projectforge.business.user.UserRightAccessCheck#hasInsertAccess(org.projectforge.framework.persistence.user.entities.PFUserDO, * java.lang.Object) */ @Override public boolean hasInsertAccess(final PFUserDO user, final TeamCalDO obj) { return isOwner(user, obj) == true || accessChecker.isUserMemberOfAdminGroup(user) == true; }
/** * @see org.projectforge.business.user.UserRightAccessCheck#hasHistoryAccess(org.projectforge.framework.persistence.user.entities.PFUserDO, * java.lang.Object) */ @Override public boolean hasHistoryAccess(final PFUserDO user, final TeamCalDO obj) { if (obj == null) { return true; } return hasInsertAccess(user, obj) == true; }
private DataobjectAccessType getAccessType(final Integer calendarId, final Integer userId) { final TeamCalDO cal = teamCalCache.getCalendar(calendarId); return getTeamCalRight().getAccessType(cal, userId); }
/** * @return true if user is assignee or reporter. If not, the task access is checked. * @see org.projectforge.business.user.UserRightAccessCheck#hasSelectAccess(org.projectforge.framework.persistence.user.entities.PFUserDO, * java.lang.Object) */ @Override public boolean hasSelectAccess(final PFUserDO user, final TeamEventDO obj) { final TeamCalDO calendar = obj.getCalendar(); if (calendar == null) { return false; } if (ObjectUtils.equals(user.getId(), calendar.getOwnerId()) == true) { // User has full access to it's own calendars. return true; } final Integer userId = user.getId(); if (teamCalRight.hasFullAccess(calendar, userId) == true || teamCalRight.hasReadonlyAccess(calendar, userId) == true) { return true; } else if (teamCalRight.hasMinimalAccess(calendar, userId) == true) { // Clear fields for users with minimal access. obj.clearFields(); return true; } return false; }
public boolean hasUpdateAccess(final PFUserDO user, final TeamCalDO calendar) { if (calendar != null && calendar.isExternalSubscription() == true) { return false; } if (ObjectUtils.equals(user.getId(), calendar.getOwnerId()) == true) { // User has full access to it's own calendars. return true; } final Integer userId = user.getId(); if (teamCalRight.hasFullAccess(calendar, userId) == true || accessChecker.isDemoUser() == true) { return true; } return false; }
/** * Get ordered calendars (by title and id). * * @return All accessible calendars of the context user (as owner or with full, read-only or minimal access). */ public Collection<TeamCalDO> getAllOwnCalendars() { checkRefresh(); final Set<TeamCalDO> set = new TreeSet<TeamCalDO>(new TeamCalsComparator()); final Integer loggedInUserId = ThreadLocalUserContext.getUserId(); for (final TeamCalDO cal : calendarMap.values()) { if (teamCalRight.isOwner(loggedInUserId, cal) == true) { set.add(cal); } } return set; }
/** * Owners and administrators are able to update calendars. * * @see org.projectforge.business.user.UserRightAccessCheck#hasUpdateAccess(org.projectforge.framework.persistence.user.entities.PFUserDO, * java.lang.Object, java.lang.Object) */ @Override public boolean hasUpdateAccess(final PFUserDO user, final TeamCalDO obj, final TeamCalDO oldObj) { return hasInsertAccess(user, oldObj) == true; }