$table->head = array($strforum, $strdescription, $strdiscussionsunread);
 $table->align = array('left', 'left', 'center');
 if ($useweeks || $usesections) {
     array_unshift($table->head, $useweeks ? $strweek : $strsection);
     array_unshift($table->align, 'left');
 }
 if ($canmaybesubscribe) {
     $table->head[] = $strsubscribed;
     $table->align[] = 'center';
 }
 if ($showrss = ($canmaybesubscribe || $course->id == SITEID) && !empty($CFG->enablerssfeeds) && !empty($CFG->forumng_enablerssfeeds)) {
     $table->head[] = $strfeeds;
     $table->align[] = 'center';
 }
 // Construct forums array
 $forums = forum::get_course_forums($course, 0, forum::UNREAD_DISCUSSIONS, array(), true);
 // Display all forums
 $currentsection = 0;
 $cansubscribesomething = false;
 $canunsubscribesomething = false;
 foreach ($forums as $forum) {
     $cm = $forum->get_course_module();
     // Skip forum if it's not visible or you can't read discussions there
     if (!$cm->uservisible || !has_capability('mod/forumng:viewdiscussion', $forum->get_context())) {
         continue;
     }
     // Additional OU access restrictions
     if (class_exists('ouflags')) {
         list($accessible, $visible, $message) = is_module_student_accessible($cm, $course);
         if (!$accessible) {
             continue;
                     if ($requestingsubscribe_group && $groupid) {
                         $forum->subscribe(0, $groupid);
                         $confirmtext = get_string('subscribe_confirm_group', 'forumng');
                     } else {
                         print_error('error_invalidsubscriptionrequest', 'forumng');
                     }
                 }
             }
         }
     }
 }
 // Handle whole course
 if ($courseid) {
     $course = get_record('course', 'id', $courseid);
     require_login($course);
     $forums = forum::get_course_forums($course, 0, forum::UNREAD_NONE, array(), true);
     foreach ($forums as $forum) {
         if (!$forum->can_change_subscription()) {
             continue;
         }
         $subscription_info = $forum->get_subscription_info();
         $discussionidcount = count($subscription_info->discussionids);
         if ($subscription_info->wholeforum) {
             //subscribed to the entire forum
             $subscribed = forum::FULLY_SUBSCRIBED;
         } else {
             if ($discussionidcount == 0) {
                 $subscribed = forum::NOT_SUBSCRIBED;
             } else {
                 $subscribed = forum::PARTIALLY_SUBSCRIBED;
             }
/**
 * Create html fragment for display on myMoodle page, forums changed since
 * user last visited
 *
 * @param $courses list of courses to output information from
 * @param $htmlarray returned results appended html to display
 */
function forumng_print_overview($courses, &$htmlarray)
{
    global $USER, $CFG;
    require_once $CFG->dirroot . '/mod/forumng/forum.php';
    if (empty($courses) || !is_array($courses) || count($courses) == 0) {
        return array();
    }
    $strnumunread = get_string('discussionsunread', 'forumng');
    $strforum = get_string('modulename', 'forumng');
    foreach ($courses as $course) {
        $str = "";
        $forums = forum::get_course_forums($course, $USER->id, forum::UNREAD_DISCUSSIONS);
        if (!empty($forums)) {
            foreach ($forums as $forum) {
                // note like all mymoodle, there's no check current user can see each forum
                // ok for openlearn & vital but might need addressing if VLE ever use it
                if ($forum->has_unread_discussions()) {
                    // only listing unread, not new & unread for performance
                    $str .= '<div class="overview forumng"><div class="name">' . $strforum . ':' . ' <a title="' . $strforum . '" href="' . $forum->get_url(forum::PARAM_HTML) . '">' . $forum->get_name() . '</a></div>';
                    $str .= '<div class="info">' . $forum->get_num_unread_discussions() . ' ' . $strnumunread . '</div></div>';
                }
            }
        }
        if (!empty($str)) {
            if (!array_key_exists($course->id, $htmlarray)) {
                $htmlarray[$course->id] = array();
            }
            if (!array_key_exists('forumng', $htmlarray[$course->id])) {
                $htmlarray[$course->id]['forumng'] = '';
                // initialize, avoid warnings
            }
            $htmlarray[$course->id]['forumng'] .= $str;
        }
    }
}