use of org.olat.commons.calendar.model.CalendarUserConfiguration in project OpenOLAT by OpenOLAT.
the class HomeCalendarManager method appendPersonalCalendar.
private void appendPersonalCalendar(Identity identity, List<KalendarRenderWrapper> calendars, Map<CalendarKey, CalendarUserConfiguration> configMap) {
// get the personal calendar
if (calendarModule.isEnablePersonalCalendar()) {
try {
KalendarRenderWrapper calendarWrapper = calendarManager.getPersonalCalendar(identity);
calendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
calendarWrapper.setPrivateEventsVisible(true);
CalendarUserConfiguration config = configMap.get(calendarWrapper.getCalendarKey());
if (config != null) {
calendarWrapper.setConfiguration(config);
}
calendars.add(calendarWrapper);
} catch (Exception e) {
log.error("Cannot read personal calendar of: " + identity, e);
}
}
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project OpenOLAT by OpenOLAT.
the class CourseCalendars method getCourseCalendarWrapper.
/**
* Return only the course calendar without any group calendar
* @param ureq
* @param wControl
* @param ores
* @param ne
* @return
*/
public static KalendarRenderWrapper getCourseCalendarWrapper(UserRequest ureq, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
// add course calendar
ICourse course = CourseFactory.loadCourse(courseEnv.getCourseEnvironment().getCourseResourceableId());
KalendarRenderWrapper courseKalendarWrapper = calendarManager.getCourseCalendar(course);
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
Identity identity = ureq.getIdentity();
Roles roles = ureq.getUserSession().getRoles();
boolean isPrivileged = !courseEnv.isCourseReadOnly() && (roles.isOLATAdmin() || courseEnv.isAdmin() || (ne != null && ne.isCapabilityAccessible(CalCourseNode.EDIT_CONDITION_ID)) || RepositoryManager.getInstance().isInstitutionalRessourceManagerFor(identity, roles, cgm.getCourseEntry()));
if (isPrivileged) {
courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
courseKalendarWrapper.setPrivateEventsVisible(true);
} else {
courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
courseKalendarWrapper.setPrivateEventsVisible(courseEnv.isAdmin() || courseEnv.isCoach() || courseEnv.isParticipant());
}
CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(courseKalendarWrapper.getKalendar(), ureq.getIdentity());
if (config != null) {
courseKalendarWrapper.setConfiguration(config);
}
return courseKalendarWrapper;
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project OpenOLAT by OpenOLAT.
the class CourseCalendarController method addCalendars.
private void addCalendars(List<BusinessGroup> groups, boolean isOwner, LinkProvider linkProvider, List<KalendarRenderWrapper> calendars) {
CollaborationToolsFactory collabFactory = CollaborationToolsFactory.getInstance();
for (BusinessGroup bGroup : groups) {
CollaborationTools collabTools = collabFactory.getOrCreateCollaborationTools(bGroup);
if (!collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR))
continue;
KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
groupCalendarWrapper.setPrivateEventsVisible(true);
// set calendar access
int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
Long lCalAccess = collabTools.lookupCalendarAccess();
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 = calendarManager.findCalendarConfigForIdentity(groupCalendarWrapper.getKalendar(), getIdentity());
if (config != null) {
groupCalendarWrapper.setConfiguration(config);
}
groupCalendarWrapper.setLinkProvider(linkProvider);
calendars.add(groupCalendarWrapper);
}
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project OpenOLAT by OpenOLAT.
the class CalendarUserConfigurationDAOTest method createConfiguration.
@Test
public void createConfiguration() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Cal-1");
String calendarId = UUID.randomUUID().toString();
Kalendar calendar = new Kalendar(calendarId, CalendarManager.TYPE_USER);
CalendarUserConfiguration config = calendarDao.createCalendarUserConfiguration(calendar, user);
dbInstance.commit();
Assert.assertNotNull(config);
Assert.assertNotNull(config.getKey());
Assert.assertNotNull(config.getCreationDate());
Assert.assertNotNull(config.getLastModified());
Assert.assertEquals(calendarId, config.getCalendarId());
Assert.assertEquals(CalendarManager.TYPE_USER, config.getType());
Assert.assertEquals(user, config.getIdentity());
}
use of org.olat.commons.calendar.model.CalendarUserConfiguration in project OpenOLAT by OpenOLAT.
the class CalendarUserConfigurationDAOTest method getCalendarUserConfigurations.
@Test
public void getCalendarUserConfigurations() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Cal-2");
String calendarId = UUID.randomUUID().toString();
Kalendar calendar = new Kalendar(calendarId, CalendarManager.TYPE_COURSE);
CalendarUserConfiguration config = calendarDao.createCalendarUserConfiguration(calendar, user);
dbInstance.commit();
Assert.assertNotNull(config);
// retrieve
List<CalendarUserConfiguration> configList = calendarDao.getCalendarUserConfigurations(user);
Assert.assertNotNull(configList);
Assert.assertEquals(1, configList.size());
Assert.assertEquals(config, configList.get(0));
// paranoia check
CalendarUserConfiguration loadedConfig = configList.get(0);
Assert.assertNotNull(loadedConfig.getCreationDate());
Assert.assertNotNull(loadedConfig.getLastModified());
Assert.assertEquals(config.getKey(), loadedConfig.getKey());
Assert.assertEquals(calendarId, loadedConfig.getCalendarId());
Assert.assertEquals(CalendarManager.TYPE_COURSE, loadedConfig.getType());
Assert.assertEquals(user, loadedConfig.getIdentity());
Assert.assertTrue(loadedConfig.isVisible());
Assert.assertTrue(loadedConfig.isInAggregatedFeed());
}
Aggregations