]> git.mjollnir.org Git - moodle.git/commitdiff
UPgrade logs to new format
authormoodler <moodler>
Thu, 5 Feb 2004 05:16:29 +0000 (05:16 +0000)
committermoodler <moodler>
Thu, 5 Feb 2004 05:16:29 +0000 (05:16 +0000)
mod/journal/db/mysql.php
mod/journal/db/postgres7.php
mod/journal/edit.php
mod/journal/report.php
mod/journal/version.php

index e82d4fc5dc36ca940209a5005e4a7abffddad88b..26bd2df37de61037b5e2c1add4067c5a3f0474f7 100644 (file)
@@ -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;
 }
index 58bf01b8763f8816f3e66c16fec79e78833b2c4c..ff789cd4d1e5c5b17aab8f1813c20aa1fe5e3363 100644 (file)
@@ -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;
 }
index 548d5c0ed8fbebcfba306066e6961f400152cf49..cec5fcd98dac08eadd10cb071bca93c93c8f04fe 100644 (file)
@@ -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");
index e6f88e9f842d5c413ae2ad26210d805b225080c3..fbe7d7b2b313d77f4943e32addbfa0f57e4b7230 100644 (file)
                 $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
index 660a96ab37b5f1457f2eee677193c59c3ff63dca..b36114e59756c3286f794b4980708524fbe705ed 100644 (file)
@@ -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;