Permalink
Browse files

UPgrade logs to new format

  • Loading branch information...
1 parent 484f723 commit 8a55b998056955e28e1337426bd546f035827c41 moodler committed Feb 5, 2004
Showing with 33 additions and 5 deletions.
  1. +14 −0 mod/journal/db/mysql.php
  2. +14 −0 mod/journal/db/postgres7.php
  3. +2 −2 mod/journal/edit.php
  4. +2 −2 mod/journal/report.php
  5. +1 −1 mod/journal/version.php
View
14 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;
}
View
14 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;
}
View
4 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");
View
4 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
View
2 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;

0 comments on commit 8a55b99

Please sign in to comment.