From: moodler Date: Thu, 5 Feb 2004 05:16:29 +0000 (+0000) Subject: UPgrade logs to new format X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8a55b998056955e28e1337426bd546f035827c41;p=moodle.git UPgrade logs to new format --- diff --git a/mod/journal/db/mysql.php b/mod/journal/db/mysql.php index e82d4fc5dc..26bd2df37d 100644 --- a/mod/journal/db/mysql.php +++ b/mod/journal/db/mysql.php @@ -46,6 +46,20 @@ function journal_upgrade($oldversion) { if ($oldversion < 2004011400) { table_column("journal", "", "introformat", "integer", "2", "", "1", "not null", "intro"); } + + if ($oldversion < 2004020500) { + if ($journals = get_records("journal")) { + foreach ($journals as $journal) { + if ($cm = get_coursemodule_from_instance("journal", $journal->id, $journal->course)) { + execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' + WHERE module = 'journal' AND url = 'report.php?id=$cm->id'"); + + execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' + WHERE module = 'journal' AND url = 'view.php?id=$cm->id'"); + } + } + } + } return $result; } diff --git a/mod/journal/db/postgres7.php b/mod/journal/db/postgres7.php index 58bf01b876..ff789cd4d1 100644 --- a/mod/journal/db/postgres7.php +++ b/mod/journal/db/postgres7.php @@ -30,5 +30,19 @@ function journal_upgrade($oldversion) { table_column("journal", "", "introformat", "integer", "2", "", "1", "not null", "intro"); } + if ($oldversion < 2004020500) { + if ($journals = get_records("journal")) { + foreach ($journals as $journal) { + if ($cm = get_coursemodule_from_instance("journal", $journal->id, $journal->course)) { + execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' + WHERE module = 'journal' AND url = 'report.php?id=$cm->id'"); + + execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' + WHERE module = 'journal' AND url = 'view.php?id=$cm->id'"); + } + } + } + } + return $result; } diff --git a/mod/journal/edit.php b/mod/journal/edit.php index 548d5c0ed8..cec5fcd98d 100644 --- a/mod/journal/edit.php +++ b/mod/journal/edit.php @@ -41,7 +41,7 @@ if (! update_record("journal_entries", $newentry)) { error("Could not update your journal"); } - add_to_log($course->id, "journal", "update entry", "view.php?id=$cm->id", "$newentry->id"); + add_to_log($course->id, "journal", "update entry", "view.php?id=$cm->id", "$newentry->id", $cm->id); } else { $newentry->userid = $USER->id; $newentry->journal = $journal->id; @@ -51,7 +51,7 @@ if (! $newentry->id = insert_record("journal_entries", $newentry)) { error("Could not insert a new journal entry"); } - add_to_log($course->id, "journal", "add entry", "view.php?id=$cm->id", "$newentry->id"); + add_to_log($course->id, "journal", "add entry", "view.php?id=$cm->id", "$newentry->id", $cm->id); } redirect("view.php?id=$cm->id"); diff --git a/mod/journal/report.php b/mod/journal/report.php index e6f88e9f84..fbe7d7b2b3 100644 --- a/mod/journal/report.php +++ b/mod/journal/report.php @@ -80,10 +80,10 @@ $entrybyuser[$entry->userid]->timemarked = $timenow; } } - add_to_log($course->id, "journal", "update feedback", "report.php?id=$cm->id", "$count users"); + add_to_log($course->id, "journal", "update feedback", "report.php?id=$cm->id", "$count users", $cm->id); notify(get_string("feedbackupdated", "journal", "$count"), "green"); } else { - add_to_log($course->id, "journal", "view responses", "report.php?id=$cm->id", "$journal->id"); + add_to_log($course->id, "journal", "view responses", "report.php?id=$cm->id", "$journal->id", $cm->id); } /// Print out the journal entries diff --git a/mod/journal/version.php b/mod/journal/version.php index 660a96ab37..b36114e597 100644 --- a/mod/journal/version.php +++ b/mod/journal/version.php @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2004013101; +$module->version = 2004020500; $module->requires = 2004013101; // Requires this Moodle version $module->cron = 60;