/** * Observer for \core\event\course_created event. * * @param \core\event\course_created $event * @return void */ public static function course_created(\core\event\course_created $event) { global $CFG; $course = $event->get_record_snapshot('course', $event->objectid); $format = course_get_format($course); if ($format->supports_news() && !empty($course->newsitems)) { require_once $CFG->dirroot . '/mod/forum/lib.php'; // Auto create the announcements forum. forum_get_course_forum($event->objectid, 'news'); } }
public static function course_created(\core\event\course_created $event) { global $CFG, $DB; $course = $event->get_record_snapshot('course', $event->objectid); $activities = get_config('auth/joomdle', 'jomsocial_activities'); $groups = get_config('auth/joomdle', 'jomsocial_groups'); $autosell = get_config('auth/joomdle', 'auto_sell'); $joomla_user_groups = get_config('auth/joomdle', 'joomla_user_groups'); $use_kunena_forums = get_config('auth/joomdle', 'use_kunena_forums'); $auth_joomdle = new auth_plugin_joomdle(); /* kludge for the call_method fn to work */ if (!$course->summary) { $course->summary = ' '; } $conditions = array('id' => $course->category); $cat = $DB->get_record('course_categories', $conditions); $context = context_course::instance($course->id); $course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL); $course->summary = str_replace('pluginfile.php', '/auth/joomdle/pluginfile_joomdle.php', $course->summary); if ($activities) { $auth_joomdle->call_method('addActivityCourse', (int) $course->id, $course->fullname, $course->summary, (int) $course->category, $cat->name); } if ($groups) { $auth_joomdle->call_method('addSocialGroup', $course->fullname, get_string('auth_joomla_group_for_course', 'auth_joomdle') . ' ' . $course->fullname, (int) $course->id); } if ($autosell) { $cid = array($course->id); $auth_joomdle->call_method("sellCourse", array((int) $course->id)); } if ($joomla_user_groups) { $auth_joomdle->call_method('addUserGroups', (int) $course->id, $course->fullname); } if ($use_kunena_forums) { // Create section $auth_joomdle->call_method('addForum', (int) $course->id, (int) -2, $course->fullname); // Create news forum } return true; }