// Check databases and modules and install as needed.
if (! $db->Metatables() ) {
- print_header("Setting up database", "Setting up database", "Setting up databases for the first time", "");
+ print_header("Setting up database", "Setting up database", "Setting up databases for the first time");
if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
$db->debug = true;
if ($dversion = get_field("config", "value", "name", "version")) {
if ($version > $dversion) { // upgrade
+ print_header("Upgrading database", "Upgrading database", "Upgrading main databases");
notify("Upgrading databases from version $dversion to $version...");
$db->debug=true;
if (upgrade_moodle($dversion)) {
} else {
$dversion->name = "version";
$dversion->value = $version;
+ print_header("Upgrading database", "Upgrading database", "Upgrading main databases");
if (insert_record("config", $dversion)) {
notify("You are currently using Moodle version $version");
print_heading("<A HREF=\"index.php\">Continue</A>");
print_header("Setting up database", "Setting up database", "Setting up module tables", "");
}
$updated_modules = true;
+ $db->debug = true;
if (modify_database("$fullmod/db/$CFG->dbtype.sql")) {
+ $db->debug = false;
if ($module->id = insert_record("modules", $module)) {
notify("$module->name tables have been set up correctly");
} else {
$usernew->timemodified = time();
if (update_record("user", $usernew)) {
+ if ($usernew->id == $USER->id) { // Reload admin
+ $USER = get_user_info_from_db("id", $usernew->id);
+ $USER->loggedin = true;
+ set_moodle_cookie($USER->username);
+ }
redirect("index.php", "Changes saved");
} else {
error("Could not update the user record ($user->id)");
<tr valign=top>
<td><P><? print_string("format") ?>:</td>
<td><?
- choose_from_menu ($FORMATS, "format", "$form->format");
+ choose_from_menu ($COURSE_FORMATS, "format", "$form->format");
formerr($err["format"]);
?>
</td>
$form = $section;
}
- $sectionname = $SECTION[$course->format];
+ $sectionname = $COURSE_SECTION[$course->format];
print_header("Edit $sectionname $section->section", "Edit $sectionname $section->section", "", "form.summary");
<? // $Id$
-$MAXNEWSDISPLAY = 4;
-
-$FORMATS = array (
+$COURSE_FORMATS = array (
"weeks" => "Weekly layout",
"social" => "Social layout",
"topics" => "Topics layout"
);
-$SECTION = array (
+$COURSE_SECTION = array (
"weeks" => "week",
"social" => "section",
"topics" => "topic"
);
+$COURSE_MAX_LOG_DISPLAY = 150; // days
+
function print_log_selector_form($course, $selecteduser=0, $selecteddate="today") {
$timenow = time();
switch ($type) {
-
case "usercourse.png":
+ $COURSE_MAX_LOG_DISPLAY = $COURSE_MAX_LOG_DISPLAY * 3600 * 24; // seconds
+ if ($timenow - $course->startdate > $COURSE_MAX_LOG_DISPLAY) {
+ $course->startdate = $timenow - $COURSE_MAX_LOG_DISPLAY;
+ }
$timestart = usergetmidnight($course->startdate);
$i = 0;
while ($timestart < $timenow) {
error("This module doesn't exist");
}
- $sectionname = $SECTION[$course->format];
+ $sectionname = $COURSE_SECTION[$course->format];
if (! $form = get_record($module->name, "id", $cm->instance)) {
error("The required instance of this module doesn't exist");
error("This course doesn't exist");
}
- $sectionname = $SECTION[$course->format];
+ $sectionname = $COURSE_SECTION[$course->format];
if (! $module = get_record("modules", "name", $add)) {
error("This module type doesn't exist");
CREATE TABLE forum (
id int(10) unsigned NOT NULL auto_increment,
course int(10) unsigned NOT NULL default '0',
- type enum('discussion','news','general','social','eachuser','teacher') NOT NULL default 'general',
+ type enum('single','news','general','social','eachuser','teacher') NOT NULL default 'general',
name varchar(255) NOT NULL default '',
- intro mediumtext NOT NULL,
+ intro text NOT NULL,
open tinyint(1) unsigned NOT NULL default '0',
assessed tinyint(1) unsigned NOT NULL default '0',
+ forcesubscribe tinyint(1) unsigned NOT NULL default '0',
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id)
CREATE TABLE forum_posts (
id int(10) unsigned NOT NULL auto_increment,
- discuss int(10) unsigned NOT NULL default '0',
+ discussion int(10) unsigned NOT NULL default '0',
parent int(10) unsigned NOT NULL default '0',
user int(10) unsigned NOT NULL default '0',
created int(10) unsigned NOT NULL default '0',