$cm->modname = $mod->mod;
$cm->name = urldecode($mod->name);
$cm->visible = $mod->visible;
- $cm->section = $mod->section;
+ $cm->sectionnum = $mod->section;
$cm->groupmode = $mod->groupmode;
$cm->groupingid = $mod->groupingid;
$cm->groupmembersonly = $mod->groupmembersonly;
$modinfo->cms[$cm->id] =& $cm;
// reconstruct sections
- if (!isset($modinfo->sections[$cm->section])) {
- $modinfo->sections[$cm->section] = array();
+ if (!isset($modinfo->sections[$cm->sectionnum])) {
+ $modinfo->sections[$cm->sectionnum] = array();
}
- $modinfo->sections[$cm->section][] = $cm->id;
+ $modinfo->sections[$cm->sectionnum][] = $cm->id;
unset($cm);
}
+ unset($cache[$course->id]); // prevent potential reference problems when switching users
$cache[$course->id] = $modinfo;
return $cache[$course->id];
}
} else if (is_numeric($param->modid)) {
- $section = $sections[$modinfo->cms[$param->modid]->section];
+ $section = $sections[$modinfo->cms[$param->modid]->sectionnum];
$section->sequence = $param->modid;
$sections = array($section->sequence=>$section);
}
$section = 0;
$activity_count = count($activities);
+ $viewfullnames = array();
foreach ($activities as $key => $activity) {
} else {
+ if (!isset($viewfullnames[$activity->cmid])) {
+ $cm_context = get_context_instance(CONTEXT_MODULE, $activity->cmid);
+ $viewfullnames[$activity->cmid] = has_capability('moodle/site:viewfullnames', $cm_context);
+ }
+
if (!$inbox) {
print_simple_box_start('center', '90%');
$inbox = true;
$print_recent_mod_activity = $activity->type.'_print_recent_mod_activity';
if (function_exists($print_recent_mod_activity)) {
- $print_recent_mod_activity($activity, $course->id, $detail, $modnames);
+ $print_recent_mod_activity($activity, $course->id, $detail, $modnames, $viewfullnames[$activity->cmid]);
}
}
}
continue;
}
- if ($mod->section > $course->numsections) { /// Don't show excess hidden sections
+ if ($mod->sectionnum > $course->numsections) { /// Don't show excess hidden sections
break;
}
continue;
}
- if ($mod->section > 0 and $section != $mod->section) {
- $thissection = $sections[$mod->section];
+ if ($mod->sectionnum > 0 and $section != $mod->sectionnum) {
+ $thissection = $sections[$mod->sectionnum];
if ($thissection->visible or !$course->hiddensections or
has_capability('moodle/course:viewhiddensections', $context)) {
$thissection->summary = strip_tags(format_string($thissection->summary,true));
if ($course->format == 'weeks' or empty($thissection->summary)) {
- $menu[] = '--'.$strsection ." ". $mod->section;
+ $menu[] = '--'.$strsection ." ". $mod->sectionnum;
} else {
if (strlen($thissection->summary) < ($width-3)) {
$menu[] = '--'.$thissection->summary;
$menu[] = '--'.substr($thissection->summary, 0, $width).'...';
}
}
- $section = $mod->section;
+ $section = $mod->sectionnum;
} else {
// no activities from this hidden section shown
continue;
continue;
}
- if ($mod->section > $course->numsections) { /// Don't show excess hidden sections
+ if ($mod->sectionnum > $course->numsections) { /// Don't show excess hidden sections
break;
}
continue;
}
- if ($mod->section >= 0 and $section != $mod->section) {
- $thissection = $sections[$mod->section];
+ if ($mod->sectionnum >= 0 and $section != $mod->sectionnum) {
+ $thissection = $sections[$mod->sectionnum];
if ($thissection->visible or !$course->hiddensections or
has_capability('moodle/course:viewhiddensections', $coursecontext)) {
$menu[] = '</ul></li>';
}
if ($course->format == 'weeks' or empty($thissection->summary)) {
- $item = $strsection ." ". $mod->section;
+ $item = $strsection ." ". $mod->sectionnum;
} else {
if (strlen($thissection->summary) < ($width-3)) {
$item = $thissection->summary;
$menu[] = '<ul>';
$doneheading = true;
- $section = $mod->section;
+ $section = $mod->sectionnum;
} else {
// no activities from this hidden section shown
continue;
$link = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name)."</a>";
$printsection = "";
- if ($cm->section !== $currentsection) {
- if ($cm->section) {
- $printsection = $cm->section;
+ if ($cm->sectionnum !== $currentsection) {
+ if ($cm->sectionnum) {
+ $printsection = $cm->sectionnum;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->section;
+ $currentsection = $cm->sectionnum;
}
if (!file_exists($CFG->dirroot.'/mod/assignment/type/'.$cm->assignmenttype.'/assignment.class.php')) {
$tmpactivity->type = 'assignment';
$tmpactivity->cmid = $cm->id;
$tmpactivity->name = $aname;
- $tmpactivity->section = $cm->section;
+ $tmpactivity->sectionnum = $cm->sectionnum;
$tmpactivity->timestamp = $submission->timemodified;
if ($grader) {
$link = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name)."</a>";
$printsection = '';
- if ($cm->section !== $currentsection) {
- if ($cm->section) {
- $printsection = $cm->section;
+ if ($cm->sectionnum !== $currentsection) {
+ if ($cm->sectionnum) {
+ $printsection = $cm->sectionnum;
}
if ($currentsection !== '') {
$table->data[] = 'hr';
}
- $currentsection = $cm->section;
+ $currentsection = $cm->sectionnum;
}
if ($course->format == 'weeks' or $course->format == 'topics') {
$table->data[] = array ($printsection, $link);
}
$printsection = "";
- if ($cm->section !== $currentsection) {
- if ($cm->section) {
- $printsection = $cm->section;
+ if ($cm->sectionnum !== $currentsection) {
+ if ($cm->sectionnum) {
+ $printsection = $cm->sectionnum;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->section;
+ $currentsection = $cm->sectionnum;
}
$class = $cm->visible ? '' : 'class="dimmed"';
}
if ($course->format == 'weeks' or $course->format == 'topics') {
- if ($cm->section !== $currentsection) {
- if ($cm->section) {
- $printsection = $cm->section;
+ if ($cm->sectionnum !== $currentsection) {
+ if ($cm->sectionnum) {
+ $printsection = $cm->sectionnum;
}
if ($currentsection !== '') {
$table->data[] = 'hr';
}
- $currentsection = $cm->section;
+ $currentsection = $cm->sectionnum;
}
$row = array ($printsection, $link, $cm->intro, $numrecords, $numunapprovedrecords);
if (!$posts = get_records_sql("SELECT p.*, f.type AS forumtype, d.forum, d.groupid,
d.timestart, d.timeend, d.userid AS duserid,
- u.firstname, u.lastname, u.email, u.picture
+ u.firstname, u.lastname, u.email, u.picture, u.imagealt
FROM {$CFG->prefix}forum_posts p
JOIN {$CFG->prefix}forum_discussions d ON d.id = p.discussion
JOIN {$CFG->prefix}forum f ON f.id = d.forum
$cm_context = get_context_instance(CONTEXT_MODULE, $cm->id);
$viewhiddentimed = has_capability('mod/forum:viewhiddentimedposts', $cm_context);
$accessallgroups = has_capability('moodle/site:accessallgroups', $cm_context);
- $viewfullnames = has_capability('moodle/site:viewfullnames', $cm_context);
if (is_null($modinfo->groups)) {
$modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo
$tmpactivity->type = 'forum';
$tmpactivity->cmid = $cm->id;
$tmpactivity->name = $aname;
- $tmpactivity->section = $cm->section;
+ $tmpactivity->sectionnum = $cm->sectionnum;
$tmpactivity->timestamp = $post->modified;
+ $tmpactivity->content = new object();
$tmpactivity->content->id = $post->id;
$tmpactivity->content->discussion = $post->discussion;
$tmpactivity->content->subject = format_string($post->subject);
$tmpactivity->content->parent = $post->parent;
- $tmpactivity->user->userid = $post->userid;
- $tmpactivity->user->fullname = fullname($post, $viewfullnames);
- $tmpactivity->user->picture = $post->picture;
+ $tmpactivity->user = new object();
+ $tmpactivity->user->id = $post->userid;
+ $tmpactivity->user->firstname = $post->firstname;
+ $tmpactivity->user->lastname = $post->lastname;
+ $tmpactivity->user->picture = $post->picture;
+ $tmpactivity->user->imagealt = $post->imagealt;
+ $tmpactivity->user->email = $post->email;
$activities[$index++] = $tmpactivity;
}
/**
*
*/
-function forum_print_recent_mod_activity($activity, $courseid, $detail, $modnames) {
+function forum_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames) {
global $CFG;
if ($activity->content->parent) {
echo '<table border="0" cellpadding="3" cellspacing="0" class="forum-recent">';
echo "<tr><td class=\"userpicture\" valign=\"top\">";
- print_user_picture($activity->user->userid, $courseid, $activity->user->picture);
+ print_user_picture($activity->user, $courseid);
echo "</td><td class=\"$class\">";
echo '<div class="title">';
echo '</div>';
echo '<div class="user">';
- echo "<a href=\"$CFG->wwwroot/user/view.php?id={$activity->user->userid}&course=$courseid\">"
- ."{$activity->user->fullname}</a> - ".userdate($activity->timestamp);
+ $fullname = fullname($activity->user, $viewfullnames);
+ echo "<a href=\"$CFG->wwwroot/user/view.php?id={$activity->user->id}&course=$courseid\">"
+ ."{$fullname}</a> - ".userdate($activity->timestamp);
echo '</div>';
echo "</td></tr></table>";
$link = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name)."</a>";
$printsection = "";
- if ($cm->section !== $currentsection) {
- if ($cm->section) {
- $printsection = $cm->section;
+ if ($cm->sectionnum !== $currentsection) {
+ if ($cm->sectionnum) {
+ $printsection = $cm->sectionnum;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->section;
+ $currentsection = $cm->sectionnum;
}
// TODO: count only approved if not allowed to see them
$tmpactivity->type = 'quiz';
$tmpactivity->cmid = $cm->id;
$tmpactivity->name = $aname;
- $tmpactivity->section = $cm->section;
+ $tmpactivity->sectionnum= $cm->sectionnum;
$tmpactivity->timestamp = $attempt->timefinish;
$tmpactivity->content->attemptid = $attempt->id;
if ($course->format == "weeks" or $course->format == "topics") {
$printsection = "";
- if ($cm->section !== $currentsection) {
- if ($cm->section) {
- $printsection = $cm->section;
+ if ($cm->sectionnum !== $currentsection) {
+ if ($cm->sectionnum) {
+ $printsection = $cm->sectionnum;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->section;
+ $currentsection = $cm->sectionnum;
}
} else {
$printsection = '<span class="smallinfo">'.userdate($cm->timemodified)."</span>";
$ss = $strnotdone;
}
$printsection = "";
- if ($cm->section !== $currentsection) {
- if ($cm->section) {
- $printsection = $cm->section;
+ if ($cm->sectionnum !== $currentsection) {
+ if ($cm->sectionnum) {
+ $printsection = $cm->sectionnum;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->section;
+ $currentsection = $cm->sectionnum;
}
//Calculate the href
$class = $cm->visible ? '' : 'class="dimmed"';
$wtype = '<span class="smallinfo">'.$wtype.'</span>';
if ($course->format == "weeks" or $course->format == "topics") {
- $table->data[] = array ($cm->section, $link, $summary, $wtype, $timmod);
+ $table->data[] = array ($cm->sectionnum, $link, $summary, $wtype, $timmod);
} else {
$table->data[] = array ($link, $summary, $wtype, $timmod);
}