/** * @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; }
/** * 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 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); }
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); }
/** * @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 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; }
/** * 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; }
/** * @see org.projectforge.web.wicket.CellItemListenerPropertyColumn#populateItem(org.apache.wicket.markup.repeater.Item, * java.lang.String, org.apache.wicket.model.IModel) */ @Override public void populateItem(final Item<ICellPopulator<TeamCalDO>> item, final String componentId, final IModel<TeamCalDO> rowModel) { final TeamCalDO teamCal = rowModel.getObject(); final TeamCalRight right = (TeamCalRight) teamCalDao.getUserRight(); String label; if (right.isOwner(getUser(), teamCal) == true) { label = getString("plugins.teamcal.owner"); } else if (right.hasFullAccess(teamCal, getUserId()) == true) { label = getString("plugins.teamcal.fullAccess"); } else if (right.hasReadonlyAccess(teamCal, getUserId()) == true) { label = getString("plugins.teamcal.readonlyAccess"); } else if (right.hasMinimalAccess(teamCal, getUserId()) == true) { label = getString("plugins.teamcal.minimalAccess"); } else if (isAdminUser == true) { label = getString("plugins.teamcal.adminAccess"); } else { label = "???"; } item.add(new Label(componentId, label)); cellItemListener.populateItem(item, componentId, rowModel); } });
/** * @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; }
if ((myFilter.isFullAccess() == true && right.hasFullAccess(cal, userId) == true) || (myFilter.isReadonlyAccess() == true && right.hasReadonlyAccess(cal, userId) == true) || (myFilter.isMinimalAccess() == true && right.hasMinimalAccess(cal, userId) == true)) {
public static CalendarObject getCalendarObject(final TeamCalDO src, UserRightService userRights) { if (src == null) { return null; } final Integer userId = ThreadLocalUserContext.getUserId(); final CalendarObject cal = new CalendarObject(); DOConverter.copyFields(cal, src); cal.setTitle(src.getTitle()); cal.setDescription(src.getDescription()); cal.setExternalSubscription(src.isExternalSubscription()); final TeamCalRight right = (TeamCalRight) userRights.getRight(UserRightId.PLUGIN_CALENDAR); cal.setMinimalAccess(right.hasMinimalAccess(src, userId)); cal.setReadonlyAccess(right.hasReadonlyAccess(src, userId)); cal.setFullAccess(right.hasFullAccess(src, userId)); cal.setOwner(ObjectUtils.equals(userId, src.getOwnerId())); return cal; } }
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)