/** * Adds information about unread messages, that is only required for the course view page (and * similar), to the course-module object. * @param cm_info $cm Course-module object */ function forum_cm_info_view(cm_info $cm) { global $CFG; // Get tracking status (once per request) static $initialised; static $usetracking, $strunreadpostsone; if (!isset($initialised)) { if ($usetracking = forum_tp_can_track_forums()) { $strunreadpostsone = get_string('unreadpostsone', 'forum'); } $initialised = true; } if ($usetracking) { if ($unread = forum_tp_count_forum_unread_posts($cm, $cm->get_course())) { $out = '<span class="unread"> <a href="' . $cm->get_url() . '">'; if ($unread == 1) { $out .= $strunreadpostsone; } else { $out .= get_string('unreadpostsnumber', 'forum', $unread); } $out .= '</a></span>'; $cm->set_after_link($out); } } }
/** * Adds information about unread messages, that is only required for the course view page (and * similar), to the course-module object. * @param cm_info $cm Course-module object */ function forum_cm_info_view(cm_info $cm) { global $CFG; if (forum_tp_can_track_forums()) { if ($unread = forum_tp_count_forum_unread_posts($cm, $cm->get_course())) { $out = '<span class="unread"> <a href="' . $cm->url . '">'; if ($unread == 1) { $out .= get_string('unreadpostsone', 'forum'); } else { $out .= get_string('unreadpostsnumber', 'forum', $unread); } $out .= '</a></span>'; $cm->set_after_link($out); } } }
array_unshift($learningtable->align, 'center'); if ($learningforums) { $currentsection = ''; foreach ($learningforums as $forum) { $cm = $modinfo->instances['forum'][$forum->id]; $context = context_module::instance($cm->id); $count = forum_count_discussions($forum, $cm, $course); if ($usetracking) { if ($forum->trackingtype == FORUM_TRACKING_OFF) { $unreadlink = '-'; $trackedlink = '-'; } else { if (isset($untracked[$forum->id])) { $unreadlink = '-'; } else { if ($unread = forum_tp_count_forum_unread_posts($cm, $course)) { $unreadlink = '<span class="unread"><a href="view.php?f=' . $forum->id . '">' . $unread . '</a>'; $unreadlink .= '<a title="' . $strmarkallread . '" href="markposts.php?f=' . $forum->id . '&mark=read"><img src="' . $OUTPUT->pix_url('t/markasread') . '" alt="' . $strmarkallread . '" class="iconsmall" /></a></span>'; } else { $unreadlink = '<span class="read">0</span>'; } } if ($forum->trackingtype == FORUM_TRACKING_FORCED && $CFG->forum_allowforcedreadtracking) { $trackedlink = $stryes; } else { if ($forum->trackingtype === FORUM_TRACKING_OFF || $USER->trackforums == 0) { $trackedlink = '-'; } else { $aurl = new moodle_url('/mod/forum/settracking.php', array('id' => $forum->id)); if (!isset($untracked[$forum->id])) { $trackedlink = $OUTPUT->single_button($aurl, $stryes, 'post', array('title' => $strnotrackforum));
$context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!groups_course_module_visible($cm)) { continue; } $currentgroup = groups_get_activity_group($cm); $groupmode = groups_get_activity_groupmode($cm); $cantaccessagroup = $groupmode and !has_capability('moodle/site:accessallgroups', $context) and !mygroupid($course->id); if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) { $count = count_records("forum_discussions", "forum", "{$forum->id}", "groupid", $currentgroup); } else { $count = count_records("forum_discussions", "forum", "{$forum->id}"); } if ($usetracking) { if ($forum->trackingtype == FORUM_TRACKING_ON || !isset($untracked[$forum->id])) { $groupid = $groupmode == SEPARATEGROUPS && !has_capability('moodle/site:accessallgroups', $context) ? $currentgroup : false; $unread = forum_tp_count_forum_unread_posts($USER->id, $forum->id, $groupid); if ($unread > 0) { $unreadlink = '<span class="unread"><a href="view.php?f=' . $forum->id . '">' . $unread . '</a>'; $unreadlink .= '<a title="' . $strmarkallread . '" href="markposts.php?f=' . $forum->id . '&mark=read"><img src="' . $CFG->pixpath . '/t/clear.gif" alt="' . $strmarkallread . '" /></a></span>'; } else { $unreadlink = '<span class="read"><a href="view.php?f=' . $forum->id . '">' . $unread . '</a></span>'; } if ($forum->trackingtype == FORUM_TRACKING_OPTIONAL) { $trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $stryes, 'post', '_self', true, $strnotrackforum); } } else { $unreadlink = '-'; $trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $strno, 'post', '_self', true, $strtrackforum); } } $introoptions->para = false;
/** * Prints a section full of activity modules * @Overrides course/lib.php=>print_section */ function ss_print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%", $hidecompletion=false) { #print_r($mods); global $CFG, $USER, $DB, $PAGE, $OUTPUT; static $initialised; static $groupbuttons; static $groupbuttonslink; static $isediting; static $ismoving; static $strmovehere; static $strmovefull; static $strunreadpostsone; static $usetracking; static $groupings; if (!isset($initialised)) { $groupbuttons = ($course->groupmode or (!$course->groupmodeforce)); $groupbuttonslink = (!$course->groupmodeforce); $isediting = $PAGE->user_is_editing(); $ismoving = $isediting && ismoving($course->id); if ($ismoving) { $strmovehere = get_string("movehere"); $strmovefull = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'")); } include_once($CFG->dirroot.'/mod/forum/lib.php'); if ($usetracking = forum_tp_can_track_forums()) { $strunreadpostsone = get_string('unreadpostsone', 'forum'); } $initialised = true; } $labelformatoptions = new stdClass(); $labelformatoptions->noclean = true; $labelformatoptions->overflowdiv = true; /// Casting $course->modinfo to string prevents one notice when the field is null $modinfo = get_fast_modinfo($course); $completioninfo = new completion_info($course); //Accessibility: replace table with list <ul>, but don't output empty list. if (!empty($section->sequence)) { // Fix bug #5027, don't want style=\"width:$width\". echo "<ul class=\"section img-text\">\n"; $sectionmods = explode(",", $section->sequence); foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) { continue; } $mod = $mods[$modnumber]; if ($ismoving and $mod->id == $USER->activitycopy) { // do not display moving mod continue; } if (isset($modinfo->cms[$modnumber])) { // We can continue (because it will not be displayed at all) // if: // 1) The activity is not visible to users // and // 2a) The 'showavailability' option is not set (if that is set, // we need to display the activity so we can show // availability info) // or // 2b) The 'availableinfo' is empty, i.e. the activity was // hidden in a way that leaves no info, such as using the // eye icon. if (!$modinfo->cms[$modnumber]->uservisible && (empty($modinfo->cms[$modnumber]->showavailability) || empty($modinfo->cms[$modnumber]->availableinfo))) { // visibility shortcut continue; } } else { if (!file_exists("$CFG->dirroot/mod/$mod->modname/lib.php")) { // module not installed continue; } if (!coursemodule_visible_for_user($mod) && empty($mod->showavailability)) { // full visibility check continue; } } // In some cases the activity is visible to user, but it is // dimmed. This is done if viewhiddenactivities is true and if: // 1. the activity is not visible, or // 2. the activity has dates set which do not include current, or // 3. the activity has any other conditions set (regardless of whether // current user meets them) $canviewhidden = has_capability( 'moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $mod->id)); $accessiblebutdim = false; if ($canviewhidden) { $accessiblebutdim = !$mod->visible; if (!empty($CFG->enableavailability)) { $accessiblebutdim = $accessiblebutdim || $mod->availablefrom > time() || ($mod->availableuntil && $mod->availableuntil < time()) || count($mod->conditionsgrade) > 0 || count($mod->conditionscompletion) > 0; } } $liclasses = array(); $liclasses[] = 'activity'; $liclasses[] = $mod->modname; $liclasses[] = 'modtype_'.$mod->modname; echo html_writer::start_tag('li', array('class'=>join(' ', $liclasses), 'id'=>'module-'.$modnumber)); if ($ismoving) { echo '<a title="'.$strmovefull.'"'. ' href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&sesskey='.sesskey().'">'. '<img class="movetarget" src="'.$OUTPUT->pix_url('movehere') . '" '. ' alt="'.$strmovehere.'" /></a><br /> '; } $classes = array('mod-indent'); if (!empty($mod->indent)) { $classes[] = 'mod-indent-'.$mod->indent; if ($mod->indent > 15) { $classes[] = 'mod-indent-huge'; } } echo html_writer::start_tag('div', array('class'=>join(' ', $classes))); $extra = ''; if (!empty($modinfo->cms[$modnumber]->extra)) { $extra = $modinfo->cms[$modnumber]->extra; } if ($mod->modname == "label") { if ($accessiblebutdim || !$mod->uservisible) { echo '<div class="dimmed_text"><span class="accesshide">'. get_string('hiddenfromstudents').'</span>'; } else { echo '<div>'; } echo format_text($extra, FORMAT_HTML, $labelformatoptions); echo "</div>"; if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) { if (!isset($groupings)) { $groupings = groups_get_all_groupings($course->id); } echo " <span class=\"groupinglabel\">(".format_string($groupings[$mod->groupingid]->name).')</span>'; } } else { // Normal activity $instancename = format_string($modinfo->cms[$modnumber]->name, true, $course->id); # echo format_string($modinfo->cms[$modnumber]->intro, true, $course->id); # echo format_string($modinfo->cms[$modnumber]->name, true, $course->id); # print_r($modinfo->cms[$modnumber]); $customicon = $modinfo->cms[$modnumber]->icon; if (!empty($customicon)) { if (substr($customicon, 0, 4) === 'mod/') { list($modname, $iconname) = explode('/', substr($customicon, 4), 2); $icon = $OUTPUT->pix_url($iconname, $modname); } else { $icon = $OUTPUT->pix_url($customicon); } } else { $icon = $OUTPUT->pix_url('icon', $mod->modname); } //Accessibility: for files get description via icon, this is very ugly hack! $altname = ''; $altname = $mod->modfullname; if (!empty($customicon)) { $archetype = plugin_supports('mod', $mod->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER); if ($archetype == MOD_ARCHETYPE_RESOURCE) { $mimetype = mimeinfo_from_icon('type', $customicon); $altname = get_mimetype_description($mimetype); } } // Avoid unnecessary duplication. if (false !== stripos($instancename, $altname)) { $altname = ''; } // File type after name, for alphabetic lists (screen reader). if ($altname) { $altname = get_accesshide(' '.$altname); } // We may be displaying this just in order to show information // about visibility, without the actual link if ($mod->uservisible) { // Display normal module link if (!$accessiblebutdim) { $linkcss = ''; $accesstext =''; } else { $linkcss = ' class="dimmed" '; $accesstext = '<span class="accesshide">'. get_string('hiddenfromstudents').': </span>'; } echo '<a '.$linkcss.' '.$extra. ' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'. '<img src="'.$icon.'" class="activityicon" alt="'.get_string('modulename',$mod->modname).'" /> '. $accesstext.'<span class="instancename">'.$instancename.$altname.'</span></a>'; if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) { if (!isset($groupings)) { $groupings = groups_get_all_groupings($course->id); } echo " <span class=\"groupinglabel\">(".format_string($groupings[$mod->groupingid]->name).')</span>'; } } else { // Display greyed-out text of link echo '<span class="dimmed_text" '.$extra.' ><span class="accesshide">'. get_string('notavailableyet','condition').': </span>'. '<img src="'.$icon.'" class="activityicon" alt="'.get_string('modulename', $mod->modname).'" /> <span>'. $instancename.$altname.'</span></span>'; } } if ($usetracking && $mod->modname == 'forum') { if ($unread = forum_tp_count_forum_unread_posts($mod, $course)) { echo '<span class="unread"> <a href="'.$CFG->wwwroot.'/mod/forum/view.php?id='.$mod->id.'">'; if ($unread == 1) { echo $strunreadpostsone; } else { print_string('unreadpostsnumber', 'forum', $unread); } echo '</a></span>'; } } if ($isediting) { if ($groupbuttons and plugin_supports('mod', $mod->modname, FEATURE_GROUPS, 0)) { if (! $mod->groupmodelink = $groupbuttonslink) { $mod->groupmode = $course->groupmode; } } else { $mod->groupmode = false; } echo ' '; echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section); hook_make_edit_icon_button($mod, $OUTPUT); } // Completion $completion = $hidecompletion ? COMPLETION_TRACKING_NONE : $completioninfo->is_enabled($mod); if ($completion!=COMPLETION_TRACKING_NONE && isloggedin() && !isguestuser() && $mod->uservisible) { $completiondata = $completioninfo->get_data($mod,true); $completionicon = ''; if ($isediting) { switch ($completion) { case COMPLETION_TRACKING_MANUAL : $completionicon = 'manual-enabled'; break; case COMPLETION_TRACKING_AUTOMATIC : $completionicon = 'auto-enabled'; break; default: // wtf } } else if ($completion==COMPLETION_TRACKING_MANUAL) { switch($completiondata->completionstate) { case COMPLETION_INCOMPLETE: $completionicon = 'manual-n'; break; case COMPLETION_COMPLETE: $completionicon = 'manual-y'; break; } } else { // Automatic switch($completiondata->completionstate) { case COMPLETION_INCOMPLETE: $completionicon = 'auto-n'; break; case COMPLETION_COMPLETE: $completionicon = 'auto-y'; break; case COMPLETION_COMPLETE_PASS: $completionicon = 'auto-pass'; break; case COMPLETION_COMPLETE_FAIL: $completionicon = 'auto-fail'; break; } } if ($completionicon) { $imgsrc = $OUTPUT->pix_url('i/completion-'.$completionicon); $imgalt = s(get_string('completion-alt-'.$completionicon, 'completion')); if ($completion == COMPLETION_TRACKING_MANUAL && !$isediting) { $imgtitle = s(get_string('completion-title-'.$completionicon, 'completion')); $newstate = $completiondata->completionstate==COMPLETION_COMPLETE ? COMPLETION_INCOMPLETE : COMPLETION_COMPLETE; // In manual mode the icon is a toggle form... // If this completion state is used by the // conditional activities system, we need to turn // off the JS. if (!empty($CFG->enableavailability) && condition_info::completion_value_used_as_condition($course, $mod)) { $extraclass = ' preventjs'; } else { $extraclass = ''; } echo " <form class='togglecompletion$extraclass' method='post' action='togglecompletion.php'><div> <input type='hidden' name='id' value='{$mod->id}' /> <input type='hidden' name='sesskey' value='".sesskey()."' /> <input type='hidden' name='completionstate' value='$newstate' /> <input type='image' src='$imgsrc' alt='$imgalt' title='$imgtitle' /> </div></form>"; } else { // In auto mode, or when editing, the icon is just an image echo "<span class='autocompletion'>"; echo "<img src='$imgsrc' alt='$imgalt' title='$imgalt' /></span>"; } } } // Show availability information (for someone who isn't allowed to // see the activity itself, or for staff) if (!$mod->uservisible) { echo '<div class="availabilityinfo">'.$mod->availableinfo.'</div>'; } else if ($canviewhidden && !empty($CFG->enableavailability)) { $ci = new condition_info($mod); $fullinfo = $ci->get_full_information(); if($fullinfo) { echo '<div class="availabilityinfo">'.get_string($mod->showavailability ? 'userrestriction_visible' : 'userrestriction_hidden','condition', $fullinfo).'</div>'; } } echo hook_show_activity_intro($mod); echo html_writer::end_tag('div'); echo html_writer::end_tag('li')."\n"; } } elseif ($ismoving) { echo "<ul class=\"section\">\n"; } if ($ismoving) { echo '<li><a title="'.$strmovefull.'"'. ' href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&sesskey='.sesskey().'">'. '<img class="movetarget" src="'.$OUTPUT->pix_url('movehere') . '" '. ' alt="'.$strmovehere.'" /></a></li> '; } if (!empty($section->sequence) || $ismoving) { echo "</ul><!--class='section'-->\n\n"; } }
function print_section_newsroom($course, $section, $mods, $modnamesused, $absolute = false, $width = "100%") { /// Prints a section full of activity modules global $CFG, $USER; static $initialised; static $groupbuttons; static $groupbuttonslink; static $isediting; static $ismoving; static $strmovehere; static $strmovefull; static $strunreadpostsone; static $usetracking; static $groupings; if (!isset($initialised)) { $groupbuttons = ($course->groupmode or !$course->groupmodeforce); $groupbuttonslink = !$course->groupmodeforce; $isediting = isediting($course->id); $ismoving = $isediting && ismoving($course->id); if ($ismoving) { $strmovehere = get_string("movehere"); $strmovefull = strip_tags(get_string("movefull", "", "'{$USER->activitycopyname}'")); } include_once $CFG->dirroot . '/mod/forum/lib.php'; if ($usetracking = forum_tp_can_track_forums()) { $strunreadpostsone = get_string('unreadpostsone', 'forum'); } $initialised = true; } $labelformatoptions = new object(); $labelformatoptions->noclean = true; /// Casting $course->modinfo to string prevents one notice when the field is null $modinfo = get_fast_modinfo($course); //Acccessibility: replace table with list <ul>, but don't output empty list. if (!empty($section->sequence)) { // Fix bug #5027, don't want style=\"width:$width\". echo "<ul class=\"section img-text\">\n"; $sectionmods = explode(",", $section->sequence); foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) { continue; } $mod = $mods[$modnumber]; if ($ismoving and $mod->id == $USER->activitycopy) { // do not display moving mod continue; } if (isset($modinfo->cms[$modnumber])) { if (!$modinfo->cms[$modnumber]->uservisible) { // visibility shortcut continue; } } else { if (!file_exists("{$CFG->dirroot}/mod/{$mod->modname}/lib.php")) { // module not installed continue; } if (!coursemodule_visible_for_user($mod)) { // full visibility check continue; } } // The magic! ... if indent == 1 then ... hide module if ($mod->indent == 1) { $hiddemodule = 'hidden'; } else { $hiddemodule = ''; } echo '<li class="activity ' . $mod->modname . ' ' . $hiddemodule . '" id="module-' . $modnumber . '">'; // Unique ID if ($ismoving) { echo '<a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a><br /> '; } if ($mod->indent) { print_spacer(12, 20 * $mod->indent, false); } $extra = ''; if (!empty($modinfo->cms[$modnumber]->extra)) { $extra = $modinfo->cms[$modnumber]->extra; } if ($mod->modname == "label") { echo "<span class=\""; if (!$mod->visible) { echo 'dimmed_text'; } else { echo 'label'; } echo '">'; echo format_text($extra, FORMAT_HTML, $labelformatoptions); echo "</span>"; if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) { if (!isset($groupings)) { $groupings = groups_get_all_groupings($course->id); } echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>'; } } else { // Normal activity $instancename = format_string($modinfo->cms[$modnumber]->name, true, $course->id); if (!empty($modinfo->cms[$modnumber]->icon)) { $icon = "{$CFG->pixpath}/" . $modinfo->cms[$modnumber]->icon; } else { $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif"; } //Accessibility: for files get description via icon. $altname = ''; if ('resource' == $mod->modname) { if (!empty($modinfo->cms[$modnumber]->icon)) { $possaltname = $modinfo->cms[$modnumber]->icon; $mimetype = mimeinfo_from_icon('type', $possaltname); $altname = get_mimetype_description($mimetype); } else { $altname = $mod->modfullname; } } else { $altname = $mod->modfullname; } // Avoid unnecessary duplication. if (false !== stripos($instancename, $altname)) { $altname = ''; } // File type after name, for alphabetic lists (screen reader). if ($altname) { $altname = get_accesshide(' ' . $altname); } $linkcss = $mod->visible ? "" : " class=\"dimmed\" "; echo '<a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . $instancename . $altname . '</span></a>'; //echo " $mod->modname "; // Special NEWSPAPER magic ... show summry from resource and blog's 200 chars from each post OUBlog (nadavkav) if ($mod->modname == 'resource') { $article = get_record('resource', 'id', $mod->instance); //print_r($article ); echo "{$article->summary}"; } if ($mod->modname == 'oublog') { require_once $CFG->dirroot . '/mod/oublog/locallib.php'; $oublog = get_record('oublog', 'id', $mod->instance); if (!($oublogcm = get_coursemodule_from_instance('oublog', $oublog->id))) { //error("Course module ID was incorrect"); } $oublogcontext = get_context_instance(CONTEXT_MODULE, $oublogcm->id); //oublog_check_view_permissions($oublog, $oublogcontext, $oublogcm); $currentgroup = oublog_get_activity_group($oublogcm, true); echo '<br/>'; /// Get Posts list($posts, $recordcount) = oublog_get_posts($oublog, $oublogcontext, 0, $oublogcm, $currentgroup); //, -1, $oubloguser->id, $tag, $canaudit); $i = 0; foreach ($posts as $post) { if ($i < 3) { echo '<a href="' . $CFG->wwwroot . '/mod/oublog/viewpost.php?blog=' . $oublog->id . '&post=' . $post->id . '">' . $post->title . '</a><br/>'; $summaryformatoptions->noclean = false; echo mb_substr(format_text($post->message, FORMAT_HTML, $summaryformatoptions), 1, 600) . "<hr/>"; } if ($i > 2 and $i < 6) { echo '<a href="' . $CFG->wwwroot . '/mod/oublog/viewpost.php?blog=' . $oublog->id . '&post=' . $post->id . '">' . $post->title . '</a><br/>'; } $i++; } //print_r($article ); //echo "$article->summary"; echo '<br/><a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . get_string('more', 'format_newsroom') . '</span></a>'; } if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) { if (!isset($groupings)) { $groupings = groups_get_all_groupings($course->id); } echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>'; } } if ($usetracking && $mod->modname == 'forum') { if ($unread = forum_tp_count_forum_unread_posts($mod, $course)) { echo '<span class="unread"> <a href="' . $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id . '">'; if ($unread == 1) { echo $strunreadpostsone; } else { print_string('unreadpostsnumber', 'forum', $unread); } echo '</a></span>'; } } if ($isediting) { // TODO: we must define this as mod property! if ($groupbuttons and $mod->modname != 'label' and $mod->modname != 'resource' and $mod->modname != 'glossary') { if (!($mod->groupmodelink = $groupbuttonslink)) { $mod->groupmode = $course->groupmode; } } else { $mod->groupmode = false; } echo ' '; echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section); } echo "</li>\n"; } } elseif ($ismoving) { echo "<ul class=\"section\">\n"; } if ($ismoving) { echo '<li><a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a></li> '; } if (!empty($section->sequence) || $ismoving) { echo "</ul><!--class='section'-->\n\n"; } }
/** * Own function to print one section in a tree way */ function print_topicstree_section($course, $section, $mods, $modnamesused, $absolute = false, $width = "100%") { /// Prints a section full of activity modules global $CFG, $USER; static $initialised; static $groupbuttons; static $groupbuttonslink; static $strmovehere; static $strmovefull; static $strunreadpostsone; static $usetracking; static $groupings; $spacer = ' '; if (!isset($initialised)) { $groupbuttons = ($course->groupmode or !$course->groupmodeforce); $groupbuttonslink = !$course->groupmodeforce; include_once $CFG->dirroot . '/mod/forum/lib.php'; if ($usetracking = forum_tp_can_track_forums()) { $strunreadpostsone = get_string('unreadpostsone', 'forum'); } $initialised = true; } $labelformatoptions = new object(); $labelformatoptions->noclean = true; /// Casting $course->modinfo to string prevents one notice when the field is null $modinfo = get_fast_modinfo($course); //Acccessibility: replace table with list <ul>, but don't output empty list. if (!empty($section->sequence)) { $collapsablename = "collapsable-{$course->id}-{$section->id}"; echo '<script type="text/javascript">'; echo "//<![CDATA[\n"; /** * Can use both: * call a function: addLoadEvent(nameOfSomeFunctionToRunOnPageLoad); * execute code: addLoadEvent(function() { * // more code to run on page load * }); */ echo "addLoadEvent(function() {"; echo " compactMenu('{$collapsablename}',false,'{$spacer}± ');"; echo " stateToFromStr('{$collapsablename}', retrieveCookie('{$collapsablename}'));"; echo '});'; echo "addUnloadEvent(function() {"; echo " setCookie('{$collapsablename}',stateToFromStr('{$collapsablename}'));"; echo '});'; echo "//]]>\n"; echo '</script>'; // Fix bug #5027, don't want style=\"width:$width\". echo "<ul id=\"{$collapsablename}\" class=\"section img-text treesection\">\n"; $sectionmods = explode(",", $section->sequence); /// Preprocess all the mods, adding the necessary stuff to be able to /// output nested lists later preprocessmods4topicstree($sectionmods, $mods, $modinfo); foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) { continue; } $mod = $mods[$modnumber]; if (isset($modinfo->cms[$modnumber])) { if (!$modinfo->cms[$modnumber]->uservisible) { // visibility shortcut continue; } } else { if (!file_exists("{$CFG->dirroot}/mod/{$mod->modname}/lib.php")) { // module not installed continue; } if (!coursemodule_visible_for_user($mod)) { // full visibility check continue; } } $lastcss = ''; /// Close levels if necessary if (!empty($mod->closelevel)) { for ($n = 0; $n < $mod->closelevel; $n++) { echo '</ul></li>' . "\n"; } } if (!empty($mod->islast)) { $lastcss = 'last '; } echo '<li class="activity treeactivity ' . $lastcss . $mod->modname . '" id="module-' . $modnumber . '">'; // Unique ID /// Add spacer for activities without collapse/expand button if (empty($mod->openlevel)) { echo $spacer; } $extra = ''; if (!empty($modinfo->cms[$modnumber]->extra)) { $extra = $modinfo->cms[$modnumber]->extra; } if ($mod->modname == "label") { if (!$mod->visible) { echo "<span class=\"dimmed_text\">"; } echo format_text($extra, FORMAT_HTML, $labelformatoptions); if (!$mod->visible) { echo "</span>"; } if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) { if (!isset($groupings)) { $groupings = groups_get_all_groupings($course->id); } echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>'; } } else { // Normal activity $instancename = format_string($modinfo->cms[$modnumber]->name, true, $course->id); if (!empty($modinfo->cms[$modnumber]->icon)) { $icon = "{$CFG->pixpath}/" . $modinfo->cms[$modnumber]->icon; } else { $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif"; } //Accessibility: for files get description via icon. $altname = ''; if ('resource' == $mod->modname) { if (!empty($modinfo->cms[$modnumber]->icon)) { $possaltname = $modinfo->cms[$modnumber]->icon; $mimetype = mimeinfo_from_icon('type', $possaltname); $altname = get_mimetype_description($mimetype); } else { $altname = $mod->modfullname; } } else { $altname = $mod->modfullname; } // Avoid unnecessary duplication. if (false !== stripos($instancename, $altname)) { $altname = ''; } // File type after name, for alphabetic lists (screen reader). if ($altname) { $altname = get_accesshide(' ' . $altname); } $linkcss = $mod->visible ? "" : " class=\"dimmed\" "; echo '<a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . $instancename . $altname . '</span></a>'; if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) { if (!isset($groupings)) { $groupings = groups_get_all_groupings($course->id); } echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>'; } } if ($usetracking && $mod->modname == 'forum') { if ($unread = forum_tp_count_forum_unread_posts($mod, $course)) { echo '<span class="unread"> <a href="' . $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id . '">'; if ($unread == 1) { echo $strunreadpostsone; } else { print_string('unreadpostsnumber', 'forum', $unread); } echo '</a></span>'; } } /// Open new level if necessary, else print end of li if (isset($mod->openlevel)) { echo '<ul class="treelevel-' . ($mod->openlevel + 1) . '">' . "\n"; } else { echo "</li>\n"; } } /// End modules iterator /// Close remaining levels if necessary if (!empty($mod->indent)) { for ($n = 0; $n < $mod->indent; $n++) { echo '</ul></li>' . "\n"; } } } if (!empty($section->sequence)) { echo "</ul><!--class='section'-->\n\n"; } }
function print_section($course, $section, $mods, $modnamesused, $absolute = false, $width = "100%") { /// Prints a section full of activity modules global $CFG, $USER; static $groupbuttons; static $groupbuttonslink; static $isteacher; static $isediting; static $ismoving; static $strmovehere; static $strmovefull; static $strunreadpostsone; static $untracked; static $usetracking; $labelformatoptions = new stdClass(); if (!isset($isteacher)) { $groupbuttons = ($course->groupmode or !$course->groupmodeforce); $groupbuttonslink = !$course->groupmodeforce; $isediting = isediting($course->id); $ismoving = $isediting && ismoving($course->id); if ($ismoving) { $strmovehere = get_string("movehere"); $strmovefull = strip_tags(get_string("movefull", "", "'{$USER->activitycopyname}'")); } include_once $CFG->dirroot . '/mod/forum/lib.php'; if ($usetracking = forum_tp_can_track_forums()) { $strunreadpostsone = get_string('unreadpostsone', 'forum'); $untracked = forum_tp_get_untracked_forums($USER->id, $course->id); } } $labelformatoptions->noclean = true; /// Casting $course->modinfo to string prevents one notice when the field is null $modinfo = unserialize((string) $course->modinfo); $groupings = groups_get_all_groupings($course->id); //Acccessibility: replace table with list <ul>, but don't output empty list. if (!empty($section->sequence)) { // Fix bug #5027, don't want style=\"width:$width\". echo "<ul class=\"section img-text\">\n"; $sectionmods = explode(",", $section->sequence); foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) { continue; } $mod = $mods[$modnumber]; if (($mod->visible or has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $course->id))) && (!$ismoving || $mod->id != $USER->activitycopy) && groups_course_module_visible($mod)) { echo '<li class="activity ' . $mod->modname . '" id="module-' . $modnumber . '">'; // Unique ID if ($ismoving) { echo '<a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a><br /> '; } $instancename = urldecode($modinfo[$modnumber]->name); $instancename = format_string($instancename, true, $course->id); if (!empty($modinfo[$modnumber]->extra)) { $extra = urldecode($modinfo[$modnumber]->extra); } else { $extra = ""; } if (!empty($modinfo[$modnumber]->icon)) { $icon = "{$CFG->pixpath}/" . urldecode($modinfo[$modnumber]->icon); } else { $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif"; } if ($mod->indent) { print_spacer(12, 20 * $mod->indent, false); } if ($mod->modname == "label") { if (!$mod->visible) { echo "<span class=\"dimmed_text\">"; } echo format_text($extra, FORMAT_HTML, $labelformatoptions); if (!$mod->visible) { echo "</span>"; } } else { // Normal activity //Accessibility: for files get description via icon. $altname = ''; if ('resource' == $mod->modname) { if (!empty($modinfo[$modnumber]->icon)) { $possaltname = $modinfo[$modnumber]->icon; $mimetype = mimeinfo_from_icon('type', $possaltname); $altname = get_mimetype_description($mimetype); } else { $altname = $mod->modfullname; } } else { $altname = $mod->modfullname; } // Avoid unnecessary duplication. if (false !== stripos($instancename, $altname)) { $altname = ''; } // File type after name, for alphabetic lists (screen reader). if ($altname) { $altname = get_accesshide(' ' . $altname); } $linkcss = $mod->visible ? "" : " class=\"dimmed\" "; echo '<a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . $instancename . $altname . '</span></a>'; if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) { echo " <span class=\"groupinglabel\"> - " . format_string($groupings[$mod->groupingid]->name) . '</span>'; } } if ($usetracking && $mod->modname == 'forum') { $groupmode = groups_get_course_groupmode($course, $mod); $groupid = $groupmode == SEPARATEGROUPS && !has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id)) ? groups_get_course_group($course, true) : false; if (forum_tp_can_track_forums() && !isset($untracked[$mod->instance])) { $unread = forum_tp_count_forum_unread_posts($USER->id, $mod->instance, $groupid); if ($unread) { echo '<span class="unread"> <a href="' . $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id . '">'; if ($unread == 1) { echo $strunreadpostsone; } else { print_string('unreadpostsnumber', 'forum', $unread); } echo '</a> </span>'; } } } if ($isediting) { // TODO: we must define this as mod property! if ($groupbuttons and $mod->modname != 'label' and $mod->modname != 'resource' and $mod->modname != 'glossary') { if (!($mod->groupmodelink = $groupbuttonslink)) { $mod->groupmode = $course->groupmode; } } else { $mod->groupmode = false; } echo ' '; echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section); } echo "</li>\n"; } } } elseif ($ismoving) { echo "<ul class=\"section\">\n"; } if ($ismoving) { echo '<li><a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a></li> '; } if (!empty($section->sequence) || $ismoving) { echo "</ul><!--class='section'-->\n\n"; } }
function print_section_fn(&$section, $absolute = false, $width = "100%") { /// Prints a section full of activity modules global $CFG, $USER, $THEME; static $initialised; static $groupbuttons; static $groupbuttonslink; static $isteacher, $isteacheredit; static $isediting; static $ismoving; static $strmovehere; static $strmovefull; static $strunreadpostsone; $labelformatoptions = new stdClass(); if (!isset($isteacher)) { $groupbuttons = $this->course->groupmode; $groupbuttonslink = !$this->course->groupmodeforce; $isteacher = has_capability('moodle/grade:viewall', $this->context); $isteacheredit = has_capability('moodle/course:manageactivities', $this->context); $isediting = isediting($this->course->id); $ismoving = ismoving($this->course->id); if ($ismoving) { $strmovehere = get_string("movehere"); $strmovefull = strip_tags(get_string("movefull", "", "'{$USER->activitycopyname}'")); } } if (!isset($initialised)) { include_once $CFG->dirroot . '/mod/forum/lib.php'; if ($usetracking = forum_tp_can_track_forums()) { $strunreadpostsone = get_string('unreadpostsone', 'forum'); } $initialised = true; } // Replace this with language file changes (eventually). $link_title = array('resource' => 'Lesson', 'choice' => 'Opinion', 'lesson' => 'Reading'); $labelformatoptions->noclean = true; $modinfo = unserialize($this->course->modinfo); echo "<table cellpadding=\"1\" cellspacing=\"0\" align=\"center\" width=\"{$width}\">\n"; if (!empty($section->sequence)) { $sectionmods = explode(",", $section->sequence); foreach ($sectionmods as $modnumber) { if (empty($this->mods[$modnumber])) { continue; } $mod = $this->mods[$modnumber]; /// mrc - 20042312 - Begin G8 First Nations School Customization: /// Added check for 'teacheredit' in order to hide invisible activities from /// non-editing teachers. /// if ($mod->visible or $isteacher) { if ($mod->visible or $isteacheredit) { /// mrc - 20042312 - End G8 First Nations School Customization: if (right_to_left()) { $tdalign = 'right'; } else { $tdalign = 'left'; } echo "<tr><td align=\"{$tdalign}\" class=\"activity{$mod->modname}\" width=\"{$width}\">"; if ($ismoving) { if ($mod->id == $USER->activitycopy) { continue; } echo "<a title=\"{$strmovefull}\"" . " href=\"{$CFG->wwwroot}/course/mod.php?moveto={$mod->id}&sesskey={$USER->sesskey}\">" . "<img height=\"16\" width=\"80\" src=\"{$CFG->pixpath}/movehere.gif\" " . " alt=\"{$strmovehere}\" border=\"0\"></a><br />\n"; } $instancename = urldecode($modinfo[$modnumber]->name); if (!empty($CFG->filterall)) { $instancename = filter_text("<nolink>{$instancename}</nolink>", $this->course->id); } if (!empty($modinfo[$modnumber]->extra)) { $extra = urldecode($modinfo[$modnumber]->extra); } else { $extra = ""; } if (!empty($modinfo[$modnumber]->icon)) { $icon = "{$CFG->pixpath}/" . urldecode($modinfo[$modnumber]->icon); } else { $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif"; } if ($mod->indent) { print_spacer(12, 20 * $mod->indent, false); } // /// If the questionnaire is mandatory // if (($mod->modname == 'questionnaire') && empty($mandatorypopup)) { // $mandatorypopup = is_mod_mandatory($mod, $USER->id); // } if ($mod->modname == "label") { if (empty($this->course->usemandatory) || empty($mod->mandatory)) { if (!$mod->visible) { echo "<span class=\"dimmed_text\">"; } echo format_text($extra, FORMAT_HTML, $labelformatoptions); if (!$mod->visible) { echo "</span>"; } } else { if ($isediting) { $linkcss = $mod->visible ? "" : " class=\"dimmed\" "; $alttext = isset($link_title[$mod->modname]) ? $link_title[$mod->modname] : $mod->modfullname; echo "<img src=\"{$icon}\"" . " height=16 width=16 alt=\"{$alttext}\">" . " <font size=2><a title=\"{$alttext}\" {$linkcss} {$extra}" . " href=\"{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}\">{$instancename}</a></font>"; } } } else { if (!$isediting && $mod->modname == 'forum' && isset($this->course->expforumsec) && $this->course->expforumsec == $section->section) { $page = optional_param('page', 0, PARAM_INT); $changegroup = isset($_GET['group']) ? $_GET['group'] : -1; // Group change requested? $forum = get_record("forum", "id", $mod->instance); $groupmode = groupmode($this->course, $mod); // Groups are being used $currentgroup = get_and_set_current_group($this->course, $groupmode, $changegroup); forum_print_latest_discussions($this->course, $forum, $CFG->forum_manydiscussions, 'header', '', $currentgroup, $groupmode, $page); } else { // Normal activity if (!$isteacher && !empty($this->course->activitytracking)) { $act_compl = is_activity_complete($mod, $USER->id); if ($act_compl === false) { echo ' <img src="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/pix/incomplete.gif" ' . 'height="16" width="16" alt="Activity Not Completed" hspace="10" ' . 'title="Activity Not Completed">'; } else { if ($act_compl === true || is_int($act_compl) && $act_compl >= 50) { echo ' <img src="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/pix/completed.gif" ' . 'height="16" width="16" alt="Activity Completed" hspace="10" ' . 'title="Activity Completed">'; } else { if (is_int($act_compl)) { echo ' <img src="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/pix/completedpoor.gif" ' . 'height="16" width="16" alt="Activity Completed Poorly" hspace="10" ' . 'title="Activity Completed Poorly">'; } else { if ($act_compl == 'submitted') { echo ' <img src="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/pix/submitted.gif" ' . 'height="16" width="16" alt="Activity Submitted" hspace="10" ' . 'title="Activity Submitted">'; } } } } } $linkcss = $mod->visible ? "" : " class=\"dimmed\" "; $alttext = isset($link_title[$mod->modname]) ? $link_title[$mod->modname] : $mod->modfullname; echo "<img src=\"{$icon}\"" . " height=16 width=16 alt=\"{$alttext}\">" . " <font size=2><a title=\"{$alttext}\" {$linkcss} {$extra}" . " href=\"{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}\">{$instancename}</a></font>"; } } if ($usetracking && $mod->modname == 'forum') { if ($unread = forum_tp_count_forum_unread_posts($mod, $this->course)) { echo '<span class="unread"> <a href="' . $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id . '">'; if ($unread == 1) { echo $strunreadpostsone; } else { print_string('unreadpostsnumber', 'forum', $unread); } echo '</a></span>'; } } if ($isediting) { // TODO: we must define this as mod property! if ($groupbuttons and $mod->modname != 'label' and $mod->modname != 'resource' and $mod->modname != 'glossary') { if (!($mod->groupmodelink = $groupbuttonslink)) { $mod->groupmode = $course->groupmode; } } else { $mod->groupmode = false; } echo " "; echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section); // echo make_editing_buttons($mod, $absolute, true, $mod->indent); if (isadmin()) { if (empty($THEME->custompix)) { $pixpath = $CFG->wwwroot . '/pix'; } else { $pixpath = $CFG->wwwroot . '/theme/' . $CFG->theme . '/pix'; } if ($mod->hideingradebook) { echo '<a title="Show Grades" href="' . $CFG->wwwroot . '/course/view.php?id=' . $this->course->id . '&hidegrades=0&mid=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img src="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/pix/hidegrades.gif" hspace="2" height="11" width="11" border="0" /></a>'; } else { echo '<a title="Hide Grades" href="' . $CFG->wwwroot . '/course/view.php?id=' . $this->course->id . '&hidegrades=1&mid=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img src="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/pix/showgrades.gif" hspace="2" height="11" width="11" border="0" /></a>'; } if (!empty($this->course->usemandatory)) { if ($mod->mandatory) { echo '<a title="Mandatory off" href="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/mod.php?mandatory=0&id=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img src="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/pix/lock.gif" hspace="2" height="11" width="11" border="0" /></a>'; } else { echo '<a title="Mandatory on" href="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/mod.php?mandatory=1&id=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img src="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/pix/unlock.gif" hspace="2" height="11" width="11" border="0" /></a>'; } } } } echo "</td>"; echo "</tr>"; } } } if ($ismoving) { echo "<tr><td><a title=\"{$strmovefull}\"" . " href=\"mod.php?movetosection={$section->id}" . '&sesskey=' . $USER->sesskey . '">' . "<img height=\"16\" width=\"80\" src=\"{$CFG->pixpath}/movehere.gif\" " . " alt=\"{$strmovehere}\" border=\"0\"></a></td></tr>\n"; } echo "</table>\n\n"; // return $mandatorypopup; }
function print_section_dblistview($course, $section, $mods, $modnamesused, $absolute = false, $width = "100%") { /// Prints a section full of activity modules global $CFG, $USER; static $initialised; static $groupbuttons; static $groupbuttonslink; static $isediting; static $ismoving; static $strmovehere; static $strmovefull; static $strunreadpostsone; static $usetracking; static $groupings; if (!isset($initialised)) { $groupbuttons = ($course->groupmode or !$course->groupmodeforce); $groupbuttonslink = !$course->groupmodeforce; $isediting = isediting($course->id); $ismoving = $isediting && ismoving($course->id); if ($ismoving) { $strmovehere = get_string("movehere"); $strmovefull = strip_tags(get_string("movefull", "", "'{$USER->activitycopyname}'")); } include_once $CFG->dirroot . '/mod/forum/lib.php'; if ($usetracking = forum_tp_can_track_forums()) { $strunreadpostsone = get_string('unreadpostsone', 'forum'); } $initialised = true; } $labelformatoptions = new object(); $labelformatoptions->noclean = true; /// Casting $course->modinfo to string prevents one notice when the field is null $modinfo = get_fast_modinfo($course); //Acccessibility: replace table with list <ul>, but don't output empty list. if (!empty($section->sequence)) { // Fix bug #5027, don't want style=\"width:$width\". echo "<ul class=\"section img-text\">\n"; $sectionmods = explode(",", $section->sequence); foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) { continue; } $mod = $mods[$modnumber]; if ($ismoving and $mod->id == $USER->activitycopy) { // do not display moving mod continue; } if (isset($modinfo->cms[$modnumber])) { if (!$modinfo->cms[$modnumber]->uservisible) { // visibility shortcut continue; } } else { if (!file_exists("{$CFG->dirroot}/mod/{$mod->modname}/lib.php")) { // module not installed continue; } if (!coursemodule_visible_for_user($mod)) { // full visibility check continue; } } // The magic! ... if indent == 1 then ... hide module // if ($mod->indent == 1) { // $hiddemodule = 'hidden'; // } else { // $hiddemodule = ''; // } echo '<li class="activity ' . $mod->modname . ' ' . $hiddemodule . '" id="module-' . $modnumber . '">'; // Unique ID if ($ismoving) { echo '<a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a><br /> '; } if ($mod->indent) { print_spacer(12, 20 * $mod->indent, false); } $extra = ''; if (!empty($modinfo->cms[$modnumber]->extra)) { $extra = $modinfo->cms[$modnumber]->extra; } if ($mod->modname == "label") { echo "<span class=\""; if (!$mod->visible) { echo 'dimmed_text'; } else { echo 'label'; } echo '">'; echo format_text($extra, FORMAT_HTML, $labelformatoptions); echo "</span>"; if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) { if (!isset($groupings)) { $groupings = groups_get_all_groupings($course->id); } echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>'; } } else { // Normal activity $instancename = format_string($modinfo->cms[$modnumber]->name, true, $course->id); if (!empty($modinfo->cms[$modnumber]->icon)) { $icon = "{$CFG->pixpath}/" . $modinfo->cms[$modnumber]->icon; } else { $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif"; } //Accessibility: for files get description via icon. $altname = ''; if ('resource' == $mod->modname) { if (!empty($modinfo->cms[$modnumber]->icon)) { $possaltname = $modinfo->cms[$modnumber]->icon; $mimetype = mimeinfo_from_icon('type', $possaltname); $altname = get_mimetype_description($mimetype); } else { $altname = $mod->modfullname; } } else { $altname = $mod->modfullname; } // Avoid unnecessary duplication. if (false !== stripos($instancename, $altname)) { $altname = ''; } // File type after name, for alphabetic lists (screen reader). if ($altname) { $altname = get_accesshide(' ' . $altname); } $linkcss = $mod->visible ? "" : " class=\"dimmed\" "; if ($mod->modname != 'data') { echo '<a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . $instancename . $altname . '</span></a>'; } //echo " $mod->modname "; // Special DBLISTVIEW magic ... show summry from resource and blog's 200 chars from each post OUBlog (nadavkav) if ($mod->modname == 'resource') { $article = get_record('resource', 'id', $mod->instance); //print_r($article ); echo "{$article->summary}"; } if ($mod->modname == 'data') { require_once $CFG->dirroot . '/mod/data/lib.php'; if (!($data = get_record('data', 'id', $mod->instance))) { //error('Course module is incorrect'); } $sort = 0; $what = ' DISTINCT r.id, r.approved, r.timecreated, r.timemodified, r.userid, u.firstname, u.lastname '; $count = ' COUNT(DISTINCT c.recordid) '; $tables = $CFG->prefix . 'data_content c,' . $CFG->prefix . 'data_records r,' . $CFG->prefix . 'data_content cs, ' . $CFG->prefix . 'user u '; $where = 'WHERE c.recordid = r.id AND r.dataid = ' . $data->id . ' AND r.userid = u.id '; $sortorder = ' ORDER BY r.id ASC '; $searchselect = ''; // If requiredentries is not reached, only show current user's entries //if (!$requiredentries_allowed) { // $where .= ' AND u.id = ' . $USER->id; //} /// To actually fetch the records //$fromsql = "FROM $tables $advtables $where $advwhere $groupselect $approveselect $searchselect $advsearchselect"; $fromsql = "FROM {$tables} {$where} "; $sqlselect = "SELECT {$what} {$fromsql} {$sortorder}"; /// Get the actual records if (!($records = get_records_sql($sqlselect))) { // Nothing to show! } if (empty($data->listtemplate)) { //notify(get_string('nolisttemplate','data')); //data_generate_default_template($data, 'listtemplate', 0, false, false); } echo $data->listtemplateheader; data_print_template('listtemplate', $records, $data); echo $data->listtemplatefooter; //print_r($article ); //echo "$article->summary"; echo '<hr/><a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . get_string('more', 'format_dblistview') . '</span></a>'; if (!empty($data->csstemplate)) { echo '<style>' . $data->csstemplate . '</style>'; } } if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) { if (!isset($groupings)) { $groupings = groups_get_all_groupings($course->id); } echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>'; } } if ($usetracking && $mod->modname == 'forum') { if ($unread = forum_tp_count_forum_unread_posts($mod, $course)) { echo '<span class="unread"> <a href="' . $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id . '">'; if ($unread == 1) { echo $strunreadpostsone; } else { print_string('unreadpostsnumber', 'forum', $unread); } echo '</a></span>'; } } if ($isediting) { // TODO: we must define this as mod property! if ($groupbuttons and $mod->modname != 'label' and $mod->modname != 'resource' and $mod->modname != 'glossary') { if (!($mod->groupmodelink = $groupbuttonslink)) { $mod->groupmode = $course->groupmode; } } else { $mod->groupmode = false; } echo ' '; echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section); } echo "</li>\n"; } } elseif ($ismoving) { echo "<ul class=\"section\">\n"; } if ($ismoving) { echo '<li><a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a></li> '; } if (!empty($section->sequence) || $ismoving) { echo "</ul><!--class='section'-->\n\n"; } }