]> git.mjollnir.org Git - moodle.git/commitdiff
Logging new file paths from backup/restore. Since the files don't have any metadata...
authormjollnir_ <mjollnir_>
Mon, 20 Sep 2004 05:51:42 +0000 (05:51 +0000)
committermjollnir_ <mjollnir_>
Mon, 20 Sep 2004 05:51:42 +0000 (05:51 +0000)
These patches are maintained in an publicly accessible Arch repository, see: http://lists.eduforge.org/cgi-bin/archzoom.cgi/arch-eduforge@catalyst.net.nz--2004-MIRROR/moodle--eduforge--1.3.3

Index of arch patches in this commit:

arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-85
    2004-09-20 05:33:06 GMT
    Penny Leach <penny@catalyst.net.nz>
    adding log entries when restoring files
arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-86
    2004-09-20 05:34:59 GMT
    Penny Leach <penny@catalyst.net.nz>
    fix related to logging uploads

Full logs:

Revision: moodle--eduforge--1.3.3--patch-85
Archive: arch-eduforge@catalyst.net.nz--2004
Creator: Penny Leach <penny@catalyst.net.nz>
Date: Mon Sep 20 17:33:06 NZST 2004
Standard-date: 2004-09-20 05:33:06 GMT
Modified-files: backup/lib.php
New-patches: arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-85
Summary: adding log entries when restoring files
Keywords:

Revision: moodle--eduforge--1.3.3--patch-86
Archive: arch-eduforge@catalyst.net.nz--2004
Creator: Penny Leach <penny@catalyst.net.nz>
Date: Mon Sep 20 17:34:59 NZST 2004
Standard-date: 2004-09-20 05:34:59 GMT
Modified-files: lib/uploadlib.php
New-patches: arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-86
Summary: fix related to logging uploads
Keywords:

backup/lib.php
lib/uploadlib.php

index 4683a62680dd058971ea27b026e3b51fed543c9c..ab63a1597de535dfa55b9b90ccba1b6d417d0710 100644 (file)
@@ -2,6 +2,8 @@
     //This file contains all the general function needed (file manipulation...)
     //not directly part of the backup/restore utility
 
+    require_once($CFG->dirroot.'/lib/uploadlib.php');
+
     //Sets a name/value pair in backup_config table
     function backup_set_config($name, $value) {
         if (get_field("backup_config", "name", "name", $name)) {
             //$perms=fileperms($from_file);
             //return copy($from_file,$to_file) && chmod($to_file,$perms);
             umask(0000);
-            return copy($from_file,$to_file) && chmod($to_file,$CFG->directorypermissions);
+            if (copy($from_file,$to_file) && chmod($to_file,$CFG->directorypermissions)) {
+                clam_log_upload($to_file,null,true);
+                return true;
+            }
+            return false;
         }
         else if (is_dir($from_file)) {
             return backup_copy_dir($from_file,$to_file);
index 8e99cf699cc18b6e69727bf9fa65c8976eaca55a..66e81e2755ed5f42474333e083b2dc1e21c525cd 100644 (file)
@@ -611,7 +611,7 @@ function get_clam_error_code($returncode) {
 /**
  * adds a file upload to the log table so that clam can resolve the filename to the user later if necessary
  */
-function clam_log_upload($newfilepath,$course=null) {
+function clam_log_upload($newfilepath,$course=null,$nourl=false) {
     global $CFG,$USER;
     // get rid of any double // that might have appeared
     $newfilepath = preg_replace('/\/\//','/',$newfilepath);
@@ -622,7 +622,7 @@ function clam_log_upload($newfilepath,$course=null) {
     if ($course) {
         $courseid = $course->id;
     }
-    add_to_log($courseid,"upload","upload",$_SERVER['HTTP_REFERER'],$newfilepath);
+    add_to_log($courseid,"upload","upload",((!$nourl) ? substr($_SERVER['HTTP_REFERER'],0,100) : ''),$newfilepath);
 }
 
 /**
@@ -649,10 +649,28 @@ function clam_log_infected($oldfilepath='',$newfilepath='',$userid=0) {
 
 /**
  * some of the modules allow moving attachments (glossary), in which case we need to hunt down an original log and change the path.
+ * @param oldpath - the old path to the file (should be in the log)
+ * @param newpath - new path 
+ * @param update - if true, will overwrite old record (used for forum moving etc).
  */
-function clam_change_log($oldpath,$newpath) {
+function clam_change_log($oldpath,$newpath,$update=true) {
     global $CFG;
-    $sql = "UPDATE {$CFG->prefix}log SET info = '$newpath' WHERE module = 'upload' AND info = '$oldpath'";
-    execute_sql($sql);
+    
+    if (!$record = get_record("log","info",$oldpath,"module","upload")) {
+        error_log("couldn't find record");
+        return false;
+    }
+    $record->info = $newpath;
+    if ($update) {
+        if (update_record("log",$record)) {
+            error_log("updated record");
+        }
+    }
+    else {
+        unset($record->id);
+        if (insert_record("log",$record)) {
+            error_log("inserted record");
+        }
+    }
 }
 ?>
\ No newline at end of file