use of org.olat.commons.calendar.model.CalendarUserConfiguration in project OpenOLAT by OpenOLAT.
the class UserCalendarWebService method getPersonalCalendar.
private KalendarRenderWrapper getPersonalCalendar(Identity identity) {
// get the personal calendar
CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
KalendarRenderWrapper calendarWrapper = calendarManager.getPersonalCalendar(identity);
calendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
calendarWrapper.setPrivateEventsVisible(true);
CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(calendarWrapper.getKalendar(), identity);
if (config != null) {
calendarWrapper.setConfiguration(config);
}
return calendarWrapper;
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManager method getCalendarUserConfigurationsMap.
@Override
public Map<CalendarKey, CalendarUserConfiguration> getCalendarUserConfigurationsMap(IdentityRef identity, String... types) {
List<CalendarUserConfiguration> list = calendarUserConfigDao.getCalendarUserConfigurations(identity, types);
Map<CalendarKey, CalendarUserConfiguration> map = new HashMap<>();
for (CalendarUserConfiguration config : list) {
map.put(new CalendarKey(config.getCalendarId(), config.getType()), config);
}
return map;
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project OpenOLAT by OpenOLAT.
the class CollaborationManagerImpl method getCalendar.
@Override
public KalendarRenderWrapper getCalendar(BusinessGroup businessGroup, UserRequest ureq, boolean isAdmin) {
// do not use a global translator since in the fututre a collaborationtools
// may be shared among users
// get the calendar
KalendarRenderWrapper calRenderWrapper = calendarManager.getGroupCalendar(businessGroup);
boolean isOwner = businessGroupService.hasRoles(ureq.getIdentity(), businessGroup, GroupRoles.coach.name());
if (!(isAdmin || isOwner)) {
// check if participants have read/write access
int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
Long lCalAccess = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup).lookupCalendarAccess();
if (lCalAccess != null)
iCalAccess = lCalAccess.intValue();
if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_ALL) {
calRenderWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
} else {
calRenderWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
}
} else {
calRenderWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
}
CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(calRenderWrapper.getKalendar(), ureq.getIdentity());
if (config != null) {
calRenderWrapper.setConfiguration(config);
}
return calRenderWrapper;
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project OpenOLAT by OpenOLAT.
the class HomeCalendarManager method getListOfCalendarsFiles.
@Override
public List<CalendarFileInfos> getListOfCalendarsFiles(Identity identity) {
List<CalendarFileInfos> aggregatedFiles = new ArrayList<>();
Map<CalendarKey, CalendarUserConfiguration> configMap = calendarManager.getCalendarUserConfigurationsMap(identity);
// personal calendar
CalendarKey personalCalendarKey = new CalendarKey(identity.getName(), CalendarManager.TYPE_USER);
CalendarUserConfiguration personalCalendarConfig = configMap.get(personalCalendarKey);
if (calendarModule.isEnablePersonalCalendar() && (personalCalendarConfig == null || personalCalendarConfig.isInAggregatedFeed())) {
File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_USER, identity.getName());
if (iCalFile != null) {
aggregatedFiles.add(new CalendarFileInfos(identity.getName(), CalendarManager.TYPE_USER, iCalFile));
}
// reload every hour
List<CalendarFileInfos> importedCalendars = importCalendarManager.getImportedCalendarInfosForIdentity(identity, true);
aggregatedFiles.addAll(importedCalendars);
}
// group calendars
if (calendarModule.isEnableGroupCalendar()) {
SearchBusinessGroupParams groupParams = new SearchBusinessGroupParams(identity, true, true);
groupParams.addTools(CollaborationTools.TOOL_CALENDAR);
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(groupParams, null, 0, -1);
Set<BusinessGroup> resourceSet = new HashSet<>();
for (BusinessGroup group : groups) {
if (resourceSet.contains(group)) {
continue;
} else {
resourceSet.add(group);
}
String calendarId = group.getKey().toString();
CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_GROUP);
CalendarUserConfiguration calendarConfig = configMap.get(key);
if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_GROUP, calendarId);
if (iCalFile != null) {
aggregatedFiles.add(new CalendarFileInfos(calendarId, CalendarManager.TYPE_GROUP, iCalFile));
}
}
}
}
if (calendarModule.isEnableCourseElementCalendar() || calendarModule.isEnableCourseToolCalendar()) {
List<Object[]> resources = getCourses(identity);
Set<RepositoryEntry> resourceSet = new HashSet<>();
for (Object[] resource : resources) {
RepositoryEntry courseEntry = (RepositoryEntry) resource[0];
if (resourceSet.contains(courseEntry)) {
continue;
} else {
resourceSet.add(courseEntry);
}
String calendarId = courseEntry.getOlatResource().getResourceableId().toString();
CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_COURSE);
CalendarUserConfiguration calendarConfig = configMap.get(key);
if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_COURSE, calendarId);
if (iCalFile != null) {
aggregatedFiles.add(new CalendarFileInfos(calendarId, CalendarManager.TYPE_COURSE, iCalFile));
}
}
}
}
return aggregatedFiles;
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project OpenOLAT by OpenOLAT.
the class HomeCalendarManager method addCalendars.
/**
* Append the calendars of a list of groups. The groups must have their calendar tool
* enabled, this routine doesn't check it.
* @param ureq
* @param groups
* @param isOwner
* @param calendars
*/
private void addCalendars(List<BusinessGroup> groups, boolean isOwner, boolean isParticipant, List<KalendarRenderWrapper> calendars, Map<CalendarKey, CalendarUserConfiguration> configMap) {
Map<Long, Long> groupKeyToAccess = CoreSpringFactory.getImpl(CollaborationManager.class).lookupCalendarAccess(groups);
for (BusinessGroup bGroup : groups) {
try {
KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
groupCalendarWrapper.setPrivateEventsVisible(true);
// set calendar access
int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
Long lCalAccess = groupKeyToAccess.get(bGroup.getKey());
if (lCalAccess != null) {
iCalAccess = lCalAccess.intValue();
}
if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_OWNERS && !isOwner) {
groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
} else {
groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
}
CalendarUserConfiguration config = configMap.get(groupCalendarWrapper.getCalendarKey());
if (config != null) {
groupCalendarWrapper.setConfiguration(config);
}
if (isOwner || isParticipant) {
groupCalendarWrapper.setPrivateEventsVisible(true);
}
calendars.add(groupCalendarWrapper);
} catch (Exception e) {
log.error("Cannot read calendar of group: " + bGroup, e);
}
}
}
Aggregations