When you delete a forum that is marked shared - $forum->is_shared(), or the
'shared' flag in the $forumng database record - this leaves the system in a
broken state if there are any courses with clone forums that used it.
(There are two ways to delete a forum: delete the single forum or delete the
whole course that contains it. Both ought to work. I think this both end up
calling the forumng_delete_instance function.)
Could this be fixed as follows, in the delete function:
1. Get a list of all clones of this forum:
select * from mdl_forumng where originalcmid=$deletecmid;
note: might actually want to do join with course_modules so as to get cmid of
ones to delete
2. Delete all of them, each using standard moodle function that deletes a
3. Depending on the interface in the various points, maybe display information
('notify' function perhaps?) listing each shared forum being deleted. Obviously
the names are all the same, but could just give the course code like:
Also deleting clone on B747-10K
It might not be appropriate to display messages at these points, so this is
Since this is about deleting things it's probably good idea to test thoroughly.
I think the following cases need testing once this is fixed:
1. Delete a clone forum of a forum that has at least 2 clones (ie this should
not delete anything else, such as the other clone...)
2. Delete an original forum that does not have a clone.
3. Delete an original forum that has a clone.
4. Delete a course that contains an original forum that has a clone in the same
5. Delete a course that contains an original forum that has a clone in a