From: skodak Date: Mon, 4 Dec 2006 09:02:17 +0000 (+0000) Subject: MDL-7767 Guests should not be able to hide course sections - section hiding is not... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7b678e0a99c680b66051bfd2b2d0ce5a48ddcfd4;p=moodle.git MDL-7767 Guests should not be able to hide course sections - section hiding is not stored in db for guests, only session is used now; merged from MOODLE_17_STABLE --- diff --git a/course/lib.php b/course/lib.php index 3bcfd8a2b7..199c3a2925 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1027,15 +1027,13 @@ function get_all_sections($courseid) { function course_set_display($courseid, $display=0) { global $USER; - if (empty($USER->id)) { - return false; - } - if ($display == "all" or empty($display)) { $display = 0; } - if (record_exists("course_display", "userid", $USER->id, "course", $courseid)) { + if (empty($USER->id) or $USER->username == 'guest') { + //do not store settings in db for guests + } else 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; diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 53062bcb3b..9747d18945 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -111,6 +111,13 @@ function xmldb_main_upgrade($oldversion=0) { $result = $result && add_field($table, $field); } + if ($oldversion < 2006120300) { /// Delete guest course section settings + // following code can be executed repeatedly, such as when upgrading from 1.7.x - it is ok + if ($guest = get_record('user', 'username', 'guest')) { + execute_sql("DELETE FROM {$CFG->prefix}course_display where userid=$guest->id ;", true); + } + } + return $result; } diff --git a/version.php b/version.php index 5e6e0c2ee8..78ca74d1dd 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2006112200; // YYYYMMDD = date + $version = 2006120300; // YYYYMMDD = date // XY = increments within a single day $release = '1.8 dev'; // Human-friendly version name