mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 14:02:32 +02:00
MDL-12945 changing get_fast_modinfo() section property to sectionnum to prevent conflicts with real cm->section; full recent activity speedup when printing user pictures in forum; merged from MOODLE_19_STABLE
This commit is contained in:
parent
2fc1fd5947
commit
76cbde4138
@ -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];
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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[] = '</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;
|
||||
@ -5426,7 +5426,7 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid
|
||||
$menu[] = '<ul>';
|
||||
$doneheading = true;
|
||||
|
||||
$section = $mod->section;
|
||||
$section = $mod->sectionnum;
|
||||
} else {
|
||||
// no activities from this hidden section shown
|
||||
continue;
|
||||
|
@ -66,14 +66,14 @@
|
||||
$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')) {
|
||||
|
@ -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) {
|
||||
|
@ -65,14 +65,14 @@
|
||||
$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);
|
||||
|
@ -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"';
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 '<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">';
|
||||
@ -4283,8 +4287,9 @@ function forum_print_recent_mod_activity($activity, $courseid, $detail, $modname
|
||||
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>";
|
||||
|
||||
|
@ -81,14 +81,14 @@
|
||||
$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
|
||||
|
@ -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;
|
||||
|
@ -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 = '<span class="smallinfo">'.userdate($cm->timemodified)."</span>";
|
||||
|
@ -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"';
|
||||
|
@ -94,7 +94,7 @@
|
||||
$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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user