コード例 #1
0
}
/// Now let's process the learning forums
if ($course->id != SITEID) {
    // Only real courses have learning forums
    // 'format_.'$course->format only applicable when not SITEID (format_site is not a format)
    $strsectionname = get_string('sectionname', 'format_' . $course->format);
    // Add extra field for section number, at the front
    array_unshift($learningtable->head, $strsectionname);
    array_unshift($learningtable->align, 'center');
    if ($learningforums) {
        $currentsection = '';
        foreach ($learningforums as $forum) {
            $cm = $modinfo->instances['hsuforum'][$forum->id];
            $context = context_module::instance($cm->id);
            $count = hsuforum_count_discussions($forum, $cm, $course);
            if ($unread = hsuforum_count_forum_unread_posts($cm, $course)) {
                $unreadlink = '<span class="unread"><a href="view.php?f=' . $forum->id . '">' . $unread . '</a>';
            } else {
                $unreadlink = '<span class="read">0</span>';
            }
            $forum->intro = shorten_text(format_module_intro('hsuforum', $forum, $cm->id), $config->shortpost);
            if ($cm->sectionnum != $currentsection) {
                $printsection = get_section_name($course, $cm->sectionnum);
                if ($currentsection) {
                    $learningtable->data[] = 'hr';
                }
                $currentsection = $cm->sectionnum;
            } else {
                $printsection = '';
            }
            $forumname = format_string($forum->name, true);
コード例 #2
0
/**
 * Adds information about recent messages for the course view page
 * to the course-module object.
 * @param cm_info $cm Course-module object
 */
function hsuforum_cm_info_view(cm_info $cm)
{
    if (!$cm->uservisible) {
        return;
    }
    $config = get_config('hsuforum');
    $forum = hsuforum_get_cm_forum($cm);
    $out = '';
    if (empty($config->hiderecentposts) && $forum->showrecent) {
        $out .= hsuforum_recent_activity($cm->get_course(), true, 0, $forum->id);
    }
    if ($unread = hsuforum_count_forum_unread_posts($cm, $cm->get_course())) {
        $out .= '<a class="unread" href="' . $cm->url . '">';
        if ($unread == 1) {
            $out .= get_string('unreadpostsone', 'hsuforum');
        } else {
            $out .= get_string('unreadpostsnumber', 'hsuforum', $unread);
        }
        $out .= '</a>';
    }
    $cm->set_after_link($out);
}