diff --git a/course/lib.php b/course/lib.php
index 10748800f16..9f1a5353a79 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -1083,7 +1083,7 @@ function &get_fast_modinfo(&$course, $userid=0) {
$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;
@@ -1117,14 +1117,15 @@ function &get_fast_modinfo(&$course, $userid=0) {
$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];
diff --git a/course/recent.php b/course/recent.php
index 9a0d08a21ad..c94e6ddb776 100644
--- a/course/recent.php
+++ b/course/recent.php
@@ -96,7 +96,7 @@
}
} 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);
}
@@ -186,6 +186,7 @@
$section = 0;
$activity_count = count($activities);
+ $viewfullnames = array();
foreach ($activities as $key => $activity) {
@@ -228,6 +229,11 @@
} 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;
@@ -236,7 +242,7 @@
$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]);
}
}
}
diff --git a/lib/weblib.php b/lib/weblib.php
index 50a353f832e..1787eb6ae46 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -5276,7 +5276,7 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
continue;
}
- if ($mod->section > $course->numsections) { /// Don't show excess hidden sections
+ if ($mod->sectionnum > $course->numsections) { /// Don't show excess hidden sections
break;
}
@@ -5284,14 +5284,14 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
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;
@@ -5299,7 +5299,7 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
$menu[] = '--'.substr($thissection->summary, 0, $width).'...';
}
}
- $section = $mod->section;
+ $section = $mod->sectionnum;
} else {
// no activities from this hidden section shown
continue;
@@ -5396,7 +5396,7 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid
continue;
}
- if ($mod->section > $course->numsections) { /// Don't show excess hidden sections
+ if ($mod->sectionnum > $course->numsections) { /// Don't show excess hidden sections
break;
}
@@ -5404,8 +5404,8 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid
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)) {
@@ -5414,7 +5414,7 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid
$menu[] = '';
}
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;
@@ -5426,7 +5426,7 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid
$menu[] = '
';
$doneheading = true;
- $section = $mod->section;
+ $section = $mod->sectionnum;
} else {
// no activities from this hidden section shown
continue;
diff --git a/mod/assignment/index.php b/mod/assignment/index.php
index 7409f57847c..4ada3c06bfe 100644
--- a/mod/assignment/index.php
+++ b/mod/assignment/index.php
@@ -66,14 +66,14 @@
$link = "id\">".format_string($cm->name)."";
$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')) {
diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php
index 96127a5184f..f4ad07e7431 100644
--- a/mod/assignment/lib.php
+++ b/mod/assignment/lib.php
@@ -2544,7 +2544,7 @@ function assignment_get_recent_mod_activity(&$activities, &$index, $timestart, $
$tmpactivity->type = 'assignment';
$tmpactivity->cmid = $cm->id;
$tmpactivity->name = $aname;
- $tmpactivity->section = $cm->section;
+ $tmpactivity->sectionnum = $cm->sectionnum;
$tmpactivity->timestamp = $submission->timemodified;
if ($grader) {
diff --git a/mod/chat/index.php b/mod/chat/index.php
index bd20bc172e7..127aa6ecf1b 100644
--- a/mod/chat/index.php
+++ b/mod/chat/index.php
@@ -65,14 +65,14 @@
$link = "id\">".format_string($cm->name)."";
$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);
diff --git a/mod/choice/index.php b/mod/choice/index.php
index 670dcfef74c..e7283147876 100644
--- a/mod/choice/index.php
+++ b/mod/choice/index.php
@@ -58,14 +58,14 @@
}
$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"';
diff --git a/mod/data/index.php b/mod/data/index.php
index 60b4b7fcf83..cd3cd813c5e 100755
--- a/mod/data/index.php
+++ b/mod/data/index.php
@@ -116,14 +116,14 @@
}
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);
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index 3047b6592f5..8e20c3203dc 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -4173,7 +4173,7 @@ function forum_get_recent_mod_activity(&$activities, &$index, $timestart, $cours
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
@@ -4189,7 +4189,6 @@ function forum_get_recent_mod_activity(&$activities, &$index, $timestart, $cours
$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
@@ -4236,17 +4235,22 @@ function forum_get_recent_mod_activity(&$activities, &$index, $timestart, $cours
$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;
}
@@ -4257,7 +4261,7 @@ function forum_get_recent_mod_activity(&$activities, &$index, $timestart, $cours
/**
*
*/
-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) {
@@ -4269,7 +4273,7 @@ function forum_print_recent_mod_activity($activity, $courseid, $detail, $modname
echo '';
echo "| ";
- print_user_picture($activity->user->userid, $courseid, $activity->user->picture);
+ print_user_picture($activity->user, $courseid);
echo " | ";
echo ' ';
@@ -4283,8 +4287,9 @@ function forum_print_recent_mod_activity($activity, $courseid, $detail, $modname
echo ' ';
echo '';
echo " |
";
diff --git a/mod/glossary/index.php b/mod/glossary/index.php
index f71afc818ad..a6b1db3fcf5 100644
--- a/mod/glossary/index.php
+++ b/mod/glossary/index.php
@@ -81,14 +81,14 @@
$link = "id\">".format_string($cm->name)."";
$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
diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php
index 3162d4f3fde..9a5abcefe79 100644
--- a/mod/quiz/lib.php
+++ b/mod/quiz/lib.php
@@ -589,7 +589,7 @@ function quiz_get_recent_mod_activity(&$activities, &$index, $timestart, $course
$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;
diff --git a/mod/resource/index.php b/mod/resource/index.php
index 574e4cde822..e9e71dc3751 100644
--- a/mod/resource/index.php
+++ b/mod/resource/index.php
@@ -60,14 +60,14 @@
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 = ''.userdate($cm->timemodified)."";
diff --git a/mod/survey/index.php b/mod/survey/index.php
index fcbf432c324..da203dcccec 100644
--- a/mod/survey/index.php
+++ b/mod/survey/index.php
@@ -57,14 +57,14 @@
$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"';
diff --git a/mod/wiki/index.php b/mod/wiki/index.php
index 883e76c4de8..9bb4cc93cf0 100644
--- a/mod/wiki/index.php
+++ b/mod/wiki/index.php
@@ -94,7 +94,7 @@
$wtype = ''.$wtype.'';
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);
}