mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-49502 forum: New API function forum_view
This commit is contained in:
parent
20d38830ae
commit
51c378b116
@ -7763,3 +7763,33 @@ function forum_get_context($forumid, $context = null) {
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the activity completed (if required) and trigger the course_module_viewed event.
|
||||
*
|
||||
* @param stdClass $forum forum object
|
||||
* @param stdClass $course course object
|
||||
* @param stdClass $cm course module object
|
||||
* @param stdClass $context context object
|
||||
* @since Moodle 2.9
|
||||
*/
|
||||
function forum_view($forum, $course, $cm, $context) {
|
||||
|
||||
// Completion.
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Trigger course_module_viewed event.
|
||||
|
||||
$params = array(
|
||||
'context' => $context,
|
||||
'objectid' => $forum->id
|
||||
);
|
||||
|
||||
$event = \mod_forum\event\course_module_viewed::create($params);
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->add_record_snapshot('forum', $forum);
|
||||
$event->trigger();
|
||||
|
||||
}
|
||||
|
@ -100,18 +100,12 @@
|
||||
rss_add_http_header($context, 'mod_forum', $forum, $rsstitle);
|
||||
}
|
||||
|
||||
// Mark viewed if required
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
/// Print header.
|
||||
|
||||
$PAGE->set_title($forum->name);
|
||||
$PAGE->add_body_class('forumtype-'.$forum->type);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
/// Some capability checks.
|
||||
if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) {
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
@ -121,6 +115,11 @@
|
||||
notice(get_string('noviewdiscussionspermission', 'forum'));
|
||||
}
|
||||
|
||||
// Mark viewed and trigger the course_module_viewed event.
|
||||
forum_view($forum, $course, $cm, $context);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->heading(format_string($forum->name), 2);
|
||||
if (!empty($forum->intro) && $forum->type != 'single' && $forum->type != 'teacher') {
|
||||
echo $OUTPUT->box(format_module_intro('forum', $forum, $cm->id), 'generalbox', 'intro');
|
||||
@ -129,16 +128,6 @@
|
||||
/// find out current groups mode
|
||||
groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/forum/view.php?id=' . $cm->id);
|
||||
|
||||
$params = array(
|
||||
'context' => $context,
|
||||
'objectid' => $forum->id
|
||||
);
|
||||
$event = \mod_forum\event\course_module_viewed::create($params);
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->add_record_snapshot('forum', $forum);
|
||||
$event->trigger();
|
||||
|
||||
$SESSION->fromdiscussion = qualified_me(); // Return here if we post or set subscription etc
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user