diff --git a/src/main/java/org/olat/commons/calendar/ui/CalendarPersonalConfigurationController.java b/src/main/java/org/olat/commons/calendar/ui/CalendarPersonalConfigurationController.java index 4028b1766012dcfb2badda07acaaac61f3e21561..9be2244639670b3931724f662e1dcac72a5b1364 100644 --- a/src/main/java/org/olat/commons/calendar/ui/CalendarPersonalConfigurationController.java +++ b/src/main/java/org/olat/commons/calendar/ui/CalendarPersonalConfigurationController.java @@ -84,6 +84,7 @@ public class CalendarPersonalConfigurationController extends FormBasicController private int counter; private final boolean allowImport; private List<KalendarRenderWrapper> calendars; + private final KalendarRenderWrapper alwaysVisibleKalendar; @Autowired private CalendarManager calendarManager; @@ -91,10 +92,11 @@ public class CalendarPersonalConfigurationController extends FormBasicController private ImportCalendarManager importCalendarManager; public CalendarPersonalConfigurationController(UserRequest ureq, WindowControl wControl, - List<KalendarRenderWrapper> calendars, boolean allowImport) { + List<KalendarRenderWrapper> calendars, KalendarRenderWrapper alwaysVisibleKalendar, boolean allowImport) { super(ureq, wControl, "configuration"); this.calendars = calendars; this.allowImport = allowImport; + this.alwaysVisibleKalendar = alwaysVisibleKalendar; setTranslator(Util.createPackageTranslator(CalendarManager.class, getLocale(), getTranslator())); initForm(ureq); @@ -147,7 +149,12 @@ public class CalendarPersonalConfigurationController extends FormBasicController row.setColorLink(colorLink); FormLink visibleLink = uifactory.addFormLink("vis_" + (++counter), "visible", "", null, null, Link.NONTRANSLATED); - enableDisableIcons(visibleLink, row.isVisible()); + if(isAlwaysVisible(row)) { + enableDisableIcons(visibleLink, true); + visibleLink.setEnabled(false); + } else { + enableDisableIcons(visibleLink, row.isVisible()); + } visibleLink.setUserObject(row); row.setVisibleLink(visibleLink); @@ -167,6 +174,12 @@ public class CalendarPersonalConfigurationController extends FormBasicController row.setToolsLink(toolsLink); } + private boolean isAlwaysVisible(CalendarPersonalConfigurationRow row) { + if(alwaysVisibleKalendar == null) return false; + return alwaysVisibleKalendar.getKalendar().getCalendarID().equals(row.getCalendarId()) + && alwaysVisibleKalendar.getKalendar().getType().equals(row.getCalendarType()); + } + private void enableDisableIcons(FormLink link, boolean enabled) { link.setIconLeftCSS(enabled ? "o_icon o_icon_calendar_enabled" : "o_icon o_icon_calendar_disabled"); } diff --git a/src/main/java/org/olat/commons/calendar/ui/WeeklyCalendarController.java b/src/main/java/org/olat/commons/calendar/ui/WeeklyCalendarController.java index ede144f93f25d68937bd42fbb9ac6a51c92641d9..07083f73bf63151933480a209b30044a532ff5aa 100644 --- a/src/main/java/org/olat/commons/calendar/ui/WeeklyCalendarController.java +++ b/src/main/java/org/olat/commons/calendar/ui/WeeklyCalendarController.java @@ -179,7 +179,8 @@ public class WeeklyCalendarController extends FormBasicController implements Act formLayout.add("calendar", calendarEl); calendarEl.setConfigurationEnabled(true); calendarEl.setAggregatedFeedEnabled(true); - + calendarEl.setAlwaysVisibleCalendar(getCallerKalendarRenderWrapper()); + if(formLayout instanceof FormLayoutContainer) { FormLayoutContainer layoutCont = (FormLayoutContainer)formLayout; if (!isGuest && !calendarWrappers.isEmpty()) { @@ -239,7 +240,8 @@ public class WeeklyCalendarController extends FormBasicController implements Act } } } - + + @Override public void setDifferentiateManagedEvent(boolean differentiate) { calendarEl.setDifferentiateManagedEvents(differentiate); } @@ -501,6 +503,26 @@ public class WeeklyCalendarController extends FormBasicController implements Act eventCalloutCtr.activate(); } + private KalendarRenderWrapper getCallerKalendarRenderWrapper() { + if(callerOres == null || calendarWrappers == null) return null; + + String callerResId = callerOres.getResourceableId().toString(); + for(KalendarRenderWrapper calendarWrapper:calendarWrappers) { + String calendarType = calendarWrapper.getKalendar().getType(); + String calendarId = calendarWrapper.getKalendar().getCalendarID(); + if(callerResId.equals(calendarId)) { + if((WeeklyCalendarController.CALLER_COLLAB.equals(caller) && CalendarManager.TYPE_GROUP.equals(calendarType)) + || (WeeklyCalendarController.CALLER_COURSE.equals(caller) && CalendarManager.TYPE_COURSE.equals(calendarType))) { + return calendarWrapper; + } + } else if((WeeklyCalendarController.CALLER_PROFILE.equals(caller) || WeeklyCalendarController.CALLER_HOME.equals(caller)) + && CalendarManager.TYPE_USER.equals(calendarType) && calendarId.equals(callerOres.getResourceableTypeName())) { + return calendarWrapper; + } + } + return null; + } + private String getCallerCalendarUrl() { if(callerOres == null) return null; @@ -558,8 +580,10 @@ public class WeeklyCalendarController extends FormBasicController implements Act removeAsListenerAndDispose(cmc); removeAsListenerAndDispose(configurationCtrl); + KalendarRenderWrapper alwaysVisibleKalendar = getCallerKalendarRenderWrapper(); List<KalendarRenderWrapper> allCalendars = new ArrayList<>(calendarWrappers); - configurationCtrl = new CalendarPersonalConfigurationController(ureq, getWindowControl(), allCalendars, allowImport); + configurationCtrl = new CalendarPersonalConfigurationController(ureq, getWindowControl(), + allCalendars, alwaysVisibleKalendar, allowImport); listenTo(configurationCtrl); String title = translate("cal.configuration.list"); diff --git a/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarComponent.java b/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarComponent.java index 2da073f36691919292402dbe2652d4aea4ca82ec..c974812467a1bfefe30d4ae7f96c57afc191f400 100644 --- a/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarComponent.java +++ b/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarComponent.java @@ -55,6 +55,7 @@ public class FullCalendarComponent extends AbstractComponent { public static final String RECURRENCE_ID_SEP = "_xRecOOceRx_"; public static final String OCCURRENCE_ID_SEP = "_xOccOOccOx_"; + private KalendarRenderWrapper alwaysVisibleCalendar; private List<KalendarRenderWrapper> calendars = new ArrayList<>(); private Date currentDate; private String viewName = "month"; @@ -132,6 +133,21 @@ public class FullCalendarComponent extends AbstractComponent { this.differentiateManagedEvents = differentiateManagedEvents; } + public KalendarRenderWrapper getAlwaysVisibleCalendar() { + return alwaysVisibleCalendar; + } + + public void setAlwaysVisibleCalendar(KalendarRenderWrapper alwaysVisibleCalendar) { + this.alwaysVisibleCalendar = alwaysVisibleCalendar; + } + + public boolean isCalendarVisible(KalendarRenderWrapper calendar) { + return calendar.isVisible() || + (alwaysVisibleCalendar != null + && alwaysVisibleCalendar.getKalendar().getType().equals(calendar.getKalendar().getType()) + && alwaysVisibleCalendar.getKalendar().getCalendarID().equals(calendar.getKalendar().getCalendarID())); + } + /** * @see org.olat.core.gui.components.Component#doDispatchRequest(org.olat.core.gui.UserRequest) */ diff --git a/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarComponentRenderer.java b/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarComponentRenderer.java index 044b13ff6b3344ab7d83fcdc3dfad311296aed59..b2b6f635246d71c648a4bb1524207f008fca9562 100644 --- a/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarComponentRenderer.java +++ b/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarComponentRenderer.java @@ -117,7 +117,7 @@ public class FullCalendarComponentRenderer extends DefaultComponentRenderer { .append(" eventSources:["); int count = 0; for(KalendarRenderWrapper calWrapper: fcC.getCalendars()) { - if(calWrapper.isVisible()) { + if(fcC.isCalendarVisible(calWrapper)) { String calId = calWrapper.getKalendar().getCalendarID(); String color = calWrapper.getCssClass(); if(StringHelper.containsNonWhitespace(color) && color.startsWith("o_cal_")) { diff --git a/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarElement.java b/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarElement.java index d66764a7f37ff52c31e55160989d3494d3144b70..776ffbfb536228fcc82ea415afbfa1c5ae7d1934 100644 --- a/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarElement.java +++ b/src/main/java/org/olat/commons/calendar/ui/components/FullCalendarElement.java @@ -105,6 +105,14 @@ public class FullCalendarElement extends FormItemImpl { component.addCalendar(calendarWrapper); } + public KalendarRenderWrapper getAlwaysVisibleCalendar() { + return component.getAlwaysVisibleCalendar(); + } + + public void setAlwaysVisibleCalendar(KalendarRenderWrapper alwaysVisibleCalendar) { + component.setAlwaysVisibleCalendar(alwaysVisibleCalendar); + } + /** * @see org.olat.core.gui.components.form.flexible.FormItemImpl#evalFormRequest(org.olat.core.gui.UserRequest) */ diff --git a/src/main/java/org/olat/home/HomeCalendarController.java b/src/main/java/org/olat/home/HomeCalendarController.java index a41fc592b3f4b0432adbe6384162e7a4e875948b..0b9b6410b74d1bd27cc2058106d99b2f38833608 100644 --- a/src/main/java/org/olat/home/HomeCalendarController.java +++ b/src/main/java/org/olat/home/HomeCalendarController.java @@ -38,6 +38,8 @@ import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; import org.olat.core.gui.control.generic.dtabs.Activateable2; +import org.olat.core.id.Identity; +import org.olat.core.id.OLATResourceable; import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.StateEntry; import org.olat.core.util.UserSession; @@ -58,12 +60,14 @@ public class HomeCalendarController extends BasicController implements Activatea super(ureq, windowControl); this.userSession = ureq.getUserSession(); - userSession.getSingleUserEventCenter().registerFor(this, ureq.getIdentity(), OresHelper.lookupType(CalendarManager.class)); - CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, ureq.getIdentity(), OresHelper.lookupType(CalendarManager.class)); + Identity identity = ureq.getIdentity(); + userSession.getSingleUserEventCenter().registerFor(this, identity, OresHelper.lookupType(CalendarManager.class)); + CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, identity, OresHelper.lookupType(CalendarManager.class)); + OLATResourceable callerOres = OresHelper.createOLATResourceableInstanceWithoutCheck(identity.getName(), identity.getKey()); List<KalendarRenderWrapper> calendars = homeCalendarManager.getListOfCalendarWrappers(ureq, windowControl); calendarController = new WeeklyCalendarController(ureq, windowControl, calendars, - WeeklyCalendarController.CALLER_HOME, null, true); + WeeklyCalendarController.CALLER_HOME, callerOres, true); listenTo(calendarController); putInitialPanel(calendarController.getInitialComponent()); diff --git a/src/main/java/org/olat/modules/qpool/ui/tree/FinalTreeNode.java b/src/main/java/org/olat/modules/qpool/ui/tree/FinalTreeNode.java index c21486576929d7c0531e275388c0ca5d249934b9..97f7787bc726f8e053ebb5fb999fb723e0060cda 100644 --- a/src/main/java/org/olat/modules/qpool/ui/tree/FinalTreeNode.java +++ b/src/main/java/org/olat/modules/qpool/ui/tree/FinalTreeNode.java @@ -81,10 +81,7 @@ public class FinalTreeNode extends GenericTreeNode implements ControllerTreeNode ureq.getUserSession().getRoles(), taxonomyLevel); String resName = FINAL + "_" + taxonomyLevel.getIdentifier(); - if(resName.length() > 50) { - resName = resName.substring(0, 50); - } - OLATResourceable ores = OresHelper.createOLATResourceableInstance(resName, taxonomyLevel.getKey()); + OLATResourceable ores = OresHelper.createOLATResourceableInstanceWithoutCheck(resName, taxonomyLevel.getKey()); WindowControl swControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, ores, null, wControl, true); questionsCtrl = new QuestionsController(ureq, swControl, stackPanel, source, securityCallback, FINAL + taxonomyLevel.getKey(), false); diff --git a/src/main/java/org/olat/modules/qpool/ui/tree/MyTaxonomyLevelTreeNode.java b/src/main/java/org/olat/modules/qpool/ui/tree/MyTaxonomyLevelTreeNode.java index 0e481ed88fc55aff0712068f3d5f9e99ee7c1d8d..b3280eb9828a49eed4c4710ca21103a770327796 100644 --- a/src/main/java/org/olat/modules/qpool/ui/tree/MyTaxonomyLevelTreeNode.java +++ b/src/main/java/org/olat/modules/qpool/ui/tree/MyTaxonomyLevelTreeNode.java @@ -76,7 +76,7 @@ public class MyTaxonomyLevelTreeNode extends GenericTreeNode implements Controll ureq.getIdentity(), ureq.getUserSession().getRoles(), taxonomyLevel); - OLATResourceable ores = OresHelper.createOLATResourceableInstance(MY_TAX_LEVEL + "_" + taxonomyLevel.getIdentifier(), taxonomyLevel.getKey()); + OLATResourceable ores = OresHelper.createOLATResourceableInstanceWithoutCheck(MY_TAX_LEVEL + "_" + taxonomyLevel.getIdentifier(), taxonomyLevel.getKey()); WindowControl swControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, ores, null, wControl, true); questionsCtrl = new QuestionsController(ureq, swControl, stackPanel, source, securityCallback, MY_TAX_LEVEL + taxonomyLevel.getKey(), false); diff --git a/src/main/java/org/olat/modules/qpool/ui/tree/ReviewTreeNode.java b/src/main/java/org/olat/modules/qpool/ui/tree/ReviewTreeNode.java index 2e2e04920a5b17f1d37133a3504f738f50d41c17..7702fab5dcdd527ca6422aa3988a8e40027a3157 100644 --- a/src/main/java/org/olat/modules/qpool/ui/tree/ReviewTreeNode.java +++ b/src/main/java/org/olat/modules/qpool/ui/tree/ReviewTreeNode.java @@ -79,10 +79,7 @@ public class ReviewTreeNode extends GenericTreeNode implements ControllerTreeNod public Controller getController(UserRequest ureq, WindowControl wControl) { if (questionsCtrl == null) { String resName = REVIEW + "_" + taxonomyLevel.getIdentifier(); - if(resName.length() > 50) { - resName = resName.substring(0, 50); - } - OLATResourceable ores = OresHelper.createOLATResourceableInstance(resName, taxonomyLevel.getKey()); + OLATResourceable ores = OresHelper.createOLATResourceableInstanceWithoutCheck(resName, taxonomyLevel.getKey()); WindowControl swControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, ores, null, wControl, true); questionsCtrl = new QuestionsController(ureq, swControl, stackPanel, source, securityCallback, REVIEW + taxonomyLevel.getKey(), false); diff --git a/src/main/java/org/olat/user/UserInfoMainController.java b/src/main/java/org/olat/user/UserInfoMainController.java index e1c367cb292510d1d12467d3a937f1724915a66b..b960a8fcbb76ad597ad244b47d2ca1710ae1ea5e 100644 --- a/src/main/java/org/olat/user/UserInfoMainController.java +++ b/src/main/java/org/olat/user/UserInfoMainController.java @@ -343,8 +343,9 @@ public class UserInfoMainController extends MainLayoutBasicController implements OLATResourceable ores = OresHelper.createOLATResourceableType(CMD_CALENDAR); WindowControl bwControl = addToHistory(ureq, ores, null); + OLATResourceable callerOres = OresHelper.createOLATResourceableInstance(chosenIdentity.getName(), chosenIdentity.getKey()); calendarController = new WeeklyCalendarController(ureq, bwControl, calendars, - WeeklyCalendarController.CALLER_PROFILE, null, false); + WeeklyCalendarController.CALLER_PROFILE, callerOres, false); listenTo(calendarController); return calendarController; }