diff --git a/plugin/ims_lti/ImsLtiPlugin.php b/plugin/ims_lti/ImsLtiPlugin.php index c996b9fd56..2b144ea6bd 100644 --- a/plugin/ims_lti/ImsLtiPlugin.php +++ b/plugin/ims_lti/ImsLtiPlugin.php @@ -543,4 +543,17 @@ class ImsLtiPlugin extends Plugin } } } + + /** + * Avoid conflict with foreign key when deleting a course + * + * @param int $courseId + */ + public function doWhenDeletingCourse($courseId) + { + $em = Database::getManager(); + + $em->createQuery('DELETE FROM ChamiloPluginBundle:ImsLti\ImsLtiTool tool WHERE tool.course = :c_id') + ->execute(['c_id' => (int) $courseId]); + } } diff --git a/plugin/studentfollowup/StudentFollowUpPlugin.php b/plugin/studentfollowup/StudentFollowUpPlugin.php index 26864c78a3..032ddc9d36 100644 --- a/plugin/studentfollowup/StudentFollowUpPlugin.php +++ b/plugin/studentfollowup/StudentFollowUpPlugin.php @@ -240,4 +240,15 @@ class StudentFollowUpPlugin extends Plugin { return 20; } + + /** + * @param int $userId + */ + public function doWhenDeletingUser($userId) + { + $userId = (int) $userId; + + Database::query("DELETE FROM sfu_post WHERE user_id = $userId"); + Database::query("DELETE FROM sfu_post WHERE insert_user_id = $userId"); + } }