"section, id, course, summary, sequence");
}
+function course_set_display($courseid, $display=0) {
+ global $USER;
+
+ if (empty($USER)) {
+ return false;
+ }
+
+ if ($display == "all" or empty($display)) {
+ $display = 0;
+ }
+
+ if (record_exists("course_display", "userid", $USER->id, "course", $courseid)) {
+ set_field("course_display", "display", $display, "userid", $USER->id, "course", $courseid);
+ } else {
+ $record->userid = $USER->id;
+ $record->course = $courseid;
+ $record->display = $display;
+ if (!insert_record("course_display", $record)) {
+ notify("Could not save your course display!");
+ }
+ }
+
+ return $USER->display[$courseid] = $display; // Note: = not ==
+}
+
+function course_section_visible($courseid, $section) {
+/// Returns true/false depending on section visibility
+/// Can be expanded in the future to handle more complex
+/// course displays
+
+ global $USER;
+
+ if (empty($USER->display[$courseid])) {
+ return true;
+ }
+
+ return $USER->display[$courseid] == $section;
+}
+
function print_section_block($heading, $course, $section, $mods, $modnames, $modnamesused,
$absolute=true, $width="100%", $isediting=false) {
require_once("$CFG->dirroot/mod/forum/lib.php");
if (isset($topic)) {
- if ($topic == "all") {
- unset($USER->topic);
+ $displaysection = course_set_display($course->id, $topic);
+ } else {
+ if (isset($USER->display[$course->id])) { // for admins, mostly
+ $displaysection = $USER->display[$course->id];
} else {
- $USER->topic = $topic;
+ $displaysection = course_set_display($course->id, 0);
}
}
while ($section <= $course->numsections) {
- if (isset($USER->topic)) { // Just display a single topic
- if ($USER->topic != $section) {
- $section++;
- continue;
- }
+ if (!empty($displaysection) and $displaysection != $section) {
+ $section++;
+ continue;
}
$currenttopic = ($course->marker == $section);
echo "</td>";
echo "<td nowrap $colorsides valign=top align=center width=10>";
echo "<font size=1>";
- if (isset($USER->topic)) {
+ if ($displaysection == $section) {
$strshowalltopics = get_string("showalltopics");
echo "<a href=\"view.php?id=$course->id&topic=all\" title=\"$strshowalltopics\"><img src=\"$pixpath/i/all.gif\" height=25 width=16 border=0></a><br><br>";
} else {
if (isset($week)) {
- if ($week == "all") {
- unset($USER->section);
+ $displaysection = course_set_display($course->id, $week);
+ } else {
+ if (isset($USER->display[$course->id])) {
+ $displaysection = $USER->display[$course->id];
} else {
- $USER->section = $week;
+ $displaysection = course_set_display($course->id, 0);
}
}
/// Print a form to search forums
$searchform = forum_print_search_form($course, "", true);
- $searchform = "<DIV ALIGN=\"CENTER\">$searchform</DIV>";
+ $searchform = "<div align=\"center\">$searchform</div>";
print_side_block(get_string("search","forum"), $searchform);
/// Start main column
- echo "</TD><TD WIDTH=\"*\">";
+ echo "</td><td width=\"*\">";
print_heading_block(get_string("weeklyoutline"), "100%", "outlineheadingblock");
print_spacer(8, 1, true);
echo "</div>";
}
- echo "</TD>";
- echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\" class=\"weeklyoutlineside\" VALIGN=top ALIGN=CENTER WIDTH=10>";
- echo " </TD>";
- echo "</TR>";
- echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
+ echo "</td>";
+ echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=top align=center width=10>";
+ echo " </td>";
+ echo "</tr>";
+ echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>";
}
$nextweekdate = $weekdate + ($weekofseconds);
- if (isset($USER->section)) { // Just display a single week
- if ($USER->section != $week) {
- $week++;
- $weekdate = $nextweekdate;
- continue;
- }
+ if (!empty($displaysection) and $displaysection != $week) { // Check this week is visible
+ $week++;
+ $weekdate = $nextweekdate;
+ continue;
}
$thisweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
echo "</td>";
echo "<td nowrap $colorsides valign=top align=center width=10>";
echo "<font size=1>";
- if (isset($USER->section)) {
+ if ($displaysection == $week) {
$strshowallweeks = get_string("showallweeks");
echo "<a href=\"view.php?id=$course->id&week=all\" title=\"$strshowallweeks\"><img src=\"$pixpath/i/all.gif\" height=25 width=16 border=0></a></font>";
} else {
if ($students = get_records("user_students", "userid", $user->id)) {
foreach ($students as $student) {
$user->student[$student->course] = true;
+ $user->zoom[$student->course] = $student->zoom;
}
}
}
}
+ if ($displays = get_records("course_display", "userid", $user->id)) {
+ foreach ($displays as $display) {
+ $user->display[$display->course] = $display->display;
+ }
+ }
+
return $user;
}
execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX courseuserid (course,userid) ");
}
+ if ($oldversion < 2003042801) {
+ execute_sql("CREATE TABLE `{$CFG->prefix}course_display` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `course` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
+ `display` int(10) NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `id` (`id`),
+ KEY `courseuserid` (course,userid)
+ ) TYPE=MyISAM COMMENT='Stores info about how to display the course'");
+ }
+
return $result;
}
) TYPE=MyISAM COMMENT='Course categories';
# --------------------------------------------------------
+
+#
+# Table structure for table `course_display`
+#
+
+CREATE TABLE `prefix_course_display` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `course` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
+ `display` int(10) NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `id` (`id`),
+ KEY `courseuserid` (course,userid)
+) TYPE=MyISAM COMMENT='Stores info about how to display the course';
+# --------------------------------------------------------
+
+
#
# Table structure for table `course_modules`
#
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) TYPE=MyISAM COMMENT='One record per course creator';
-# --------------------------------------------------------
INSERT INTO prefix_log_display VALUES ('user', 'view', 'user', 'CONCAT(firstname," ",lastname)');
INSERT INTO prefix_log_display VALUES ('course', 'view', 'course', 'fullname');
execute_sql(" CREATE INDEX coursemoduleaction ON {$CFG->prefix}log (course,module,action) ");
execute_sql(" CREATE INDEX courseuserid ON {$CFG->prefix}log (course,userid) ");
}
+
+ if ($oldversion < 2003042801) {
+ execute_sql("CREATE TABLE {$CFG->prefix}course_display (
+ id SERIAL PRIMARY KEY,
+ course integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
+ display integer NOT NULL default '0'
+ )");
+
+ execute_sql("CREATE INDEX courseuserid ON {$CFG->prefix}course_display (course,userid)");
+ }
return $result;
}
name varchar(255) NOT NULL default ''
);
+CREATE TABLE prefix_course_display (
+ id SERIAL PRIMARY KEY,
+ course integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
+ display integer NOT NULL default '0'
+);
+
+CREATE INDEX courseuserid ON prefix_course_display (course,userid);
+
CREATE TABLE prefix_course_modules (
id SERIAL PRIMARY KEY,
course integer NOT NULL default '0',
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
-$version = 2003042701; // The current version is a date (YYYYMMDDXX)
+$version = 2003042801; // The current version is a date (YYYYMMDDXX)
$release = "1.0.9 development"; // User-friendly version number