From 7487bc6e64845546055fff1d8ff928398842b4fa Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Fri, 30 Jun 2017 08:19:39 +0200 Subject: [PATCH] OO-2816: check the course node and delete the publisher on course element deletion --- .../olat/course/nodes/AbstractFeedCourseNode.java | 13 ++++++++++++- .../webFeed/managers/FeedNotificationsHandler.java | 9 +++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/olat/course/nodes/AbstractFeedCourseNode.java b/src/main/java/org/olat/course/nodes/AbstractFeedCourseNode.java index 0a95578bd06..6a1e9c03532 100644 --- a/src/main/java/org/olat/course/nodes/AbstractFeedCourseNode.java +++ b/src/main/java/org/olat/course/nodes/AbstractFeedCourseNode.java @@ -22,9 +22,12 @@ package org.olat.course.nodes; import java.io.File; import java.util.Locale; +import org.olat.core.commons.services.notifications.NotificationsManager; +import org.olat.core.commons.services.notifications.SubscriptionContext; import org.olat.core.gui.UserRequest; import org.olat.core.gui.control.WindowControl; import org.olat.core.id.Identity; +import org.olat.course.CourseModule; import org.olat.course.ICourse; import org.olat.course.condition.Condition; import org.olat.course.condition.interpreter.ConditionInterpreter; @@ -86,7 +89,15 @@ public abstract class AbstractFeedCourseNode extends GenericCourseNode { preConditionPoster.setExpertMode(false); } } - + + @Override + public void cleanupOnDelete(ICourse course) { + super.cleanupOnDelete(course); + + SubscriptionContext subsContext = CourseModule.createSubscriptionContext(course.getCourseEnvironment(), this); + NotificationsManager.getInstance().delete(subsContext); + } + @Override protected void postImportCopyConditions(CourseEnvironmentMapper envMapper) { super.postImportCopyConditions(envMapper); diff --git a/src/main/java/org/olat/modules/webFeed/managers/FeedNotificationsHandler.java b/src/main/java/org/olat/modules/webFeed/managers/FeedNotificationsHandler.java index 8eb58055220..3474ef7ee57 100644 --- a/src/main/java/org/olat/modules/webFeed/managers/FeedNotificationsHandler.java +++ b/src/main/java/org/olat/modules/webFeed/managers/FeedNotificationsHandler.java @@ -40,6 +40,9 @@ import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; import org.olat.core.util.Util; import org.olat.core.util.resource.OresHelper; +import org.olat.course.CourseFactory; +import org.olat.course.ICourse; +import org.olat.course.nodes.CourseNode; import org.olat.modules.webFeed.models.Feed; import org.olat.modules.webFeed.models.Item; import org.olat.modules.webFeed.ui.FeedMainController; @@ -85,6 +88,12 @@ public abstract class FeedNotificationsHandler implements NotificationsHandler { } String displayName = re.getDisplayname(); if("CourseModule".equals(p.getResName())) { + ICourse course = CourseFactory.loadCourse(re); + CourseNode node = course.getRunStructure().getNode(p.getSubidentifier()); + if(node == null) { + notificationsManager.deactivate(p); + return notificationsManager.getNoSubscriptionInfo(); + } title = translator.translate(NOTIFICATIONS_HEADER_COURSE, new String[]{displayName}); } else { title = getHeader(translator, displayName); -- GitLab