]> git.mjollnir.org Git - moodle.git/commitdiff
Wiki integration with upload class.
authormjollnir_ <mjollnir_>
Mon, 8 Nov 2004 05:32:18 +0000 (05:32 +0000)
committermjollnir_ <mjollnir_>
Mon, 8 Nov 2004 05:32:18 +0000 (05:32 +0000)
Changes in two upload forms and in moodle_binary_store.php - moodle_binary_store_file

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-363
    Penny Leach <penny@catalyst.net.nz>
    wiki integration with upload class.
arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-364
    Penny Leach <penny@catalyst.net.nz>
    fixed lost submit button from last wiki upload patch, also fixed bug related to generating db id for attached files

Full logs:

Revision: moodle--eduforge--1.3.3--patch-363
Archive: arch-eduforge@catalyst.net.nz--2004
Creator: Penny Leach <penny@catalyst.net.nz>
Date: Mon Nov  8 11:18:08 NZDT 2004
Standard-date: 2004-11-07 22:18:08 GMT
Modified-files: mod/wiki/ewiki/ewiki.php
    mod/wiki/ewiki/plugins/moodle/downloads.php
    mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php
New-patches: arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-363
Summary: wiki integration with upload class.
Keywords:

Revision: moodle--eduforge--1.3.3--patch-364
Archive: arch-eduforge@catalyst.net.nz--2004
Creator: Penny Leach <penny@catalyst.net.nz>
Date: Mon Nov  8 16:01:29 NZDT 2004
Standard-date: 2004-11-08 03:01:29 GMT
Modified-files: mod/wiki/ewiki/plugins/moodle/downloads.php
    mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php
New-patches: arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-364
Summary: fixed lost submit button from last wiki upload patch, also fixed bug related to generating db id for attached files
Keywords:

mod/wiki/ewiki/ewiki.php
mod/wiki/ewiki/plugins/moodle/downloads.php
mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php

index 235c21b4f525415496ef840590f75c1d629d3c19..e22181c50b10ea09b64fdba78f746d36de3ea90c 100644 (file)
@@ -1591,6 +1591,7 @@ function ewiki_page_edit_form_final_imgupload(&$o, &$id, &$data, &$action) {
       . '<form action='
       . '"'. ewiki_script_binary("", EWIKI_IDF_INTERNAL, "", "_UPLOAD=1") .'"'
       . ' method="POST" enctype="multipart/form-data" target="_upload">'
+      . '<input type="hidden" name="MAX_FILE_SIZE" value="'.EWIKI_IMAGE_MAXSIZE.'" />'
       . '<input type="file" name="'.EWIKI_UP_UPLOAD.'"'
       . (defined("EWIKI_IMAGE_ACCEPT") ? ' accept="'.EWIKI_IMAGE_ACCEPT.'" />' : "")
       . '<input type="hidden" name="'.EWIKI_UP_BINARY.'" value="'.EWIKI_IDF_INTERNAL.'" />'
index c6819674ea266f47e8ba50156fdb45c48b72f75d..43ca502a6b578882e21441020938f37f4a74d511 100644 (file)
@@ -92,7 +92,7 @@ $ewiki_t["de"]["DWNL_ENTRY_FORMAT"] =
 
 function ewiki_page_fileupload($id, $data, $action, $def_sec="") {
 
-   global $ewiki_upload_sections, $ewiki_plugins;
+   global $CFG, $ewiki_upload_sections, $ewiki_plugins;
 
    $o = ewiki_make_title($id, $id, 2);
 
@@ -104,12 +104,12 @@ function ewiki_page_fileupload($id, $data, $action, $def_sec="") {
       $o .= '<div class="upload">'.
             '<form action="' .
             ewiki_script( ($action!="view" ? $action : ""), $id).
-            '" method="POST" enctype="multipart/form-data">' .
-            '<b>'.ewiki_t("file").'</b><br /><input type="file" name="'.EWIKI_UP_UPLOAD.'" /><br /><br />' .
-            '<input type="submit" value="' . EWIKI_PAGE_UPLOAD . '" /><br /><br />';
-
-      $o .= '<b>' . ewiki_t("comment") . '</b><br /><textarea name="comment" cols="35" rows="3"></textarea><br /><br />';
-
+          '" method="POST" enctype="multipart/form-data">' ;
+      require_once($CFG->dirroot.'/lib/uploadlib.php');
+      $o .= upload_print_form_fragment(1,array(EWIKI_UP_UPLOAD),array(ewiki_t("file")),false,null,0,0,true);
+      $o .= '<input type="submit" value="' . EWIKI_PAGE_UPLOAD . '"><br /><br />'
+          .'<b>' . ewiki_t("comment") . '</b><br /><textarea name="comment" cols="35" rows="3"></textarea><br /><br />';
+      
       if (empty($ewiki_upload_sections[$def_sec])) {
          $ewiki_upload_sections[$def_sec] = $def_sec;
       }
index ec70c5d09ae9fc8d928fb50415d6c0a78898d296..6352ed4d26beb08e2574cf165cd170e75d400230 100644 (file)
@@ -65,60 +65,25 @@ function moodle_binary_store_file(&$filename, &$id, &$meta, $ext=".bin") {
       return 0;
     }
     
-    $maxbytes = get_max_upload_file_size();
     
     $entry=wiki_get_entry($wiki, $course, $userid, $groupid);
     if(!$entry->id) {
       error("Cannot get entry.");
     }
     
-    $newfile = $_FILES["upload"];
-    if(!$id) {
-      $newfilename = clean_filename($newfile['name']);
-      $id = EWIKI_IDF_INTERNAL.$newfilename;
-    }
-    $dir=make_upload_directory("$course->id/$CFG->moddata/wiki/$wiki->id/$entry->id/$ewiki_title");
-    if ($maxbytes and $newfile['size'] > $maxbytes) {
-        return 0;
-    }
-    if (! $newfilename) {
-        notify("This file had a weird filename and couldn't be uploaded");
-    } else {
-        if (move_uploaded_file($filename, "$dir/$newfilename")) {
-            chmod("$dir/$newfilename", $CFG->directorypermissions);
-            $meta["binary_store"]=$ewiki_title;
-            $filename="";
-            return true;
-        } else {
-            notify("An error happened while saving the file on the server");
-            return false;
+    require_once($CFG->dirroot.'/lib/uploadlib.php');
+    $um = new upload_manager('upload',false,false,$course,false,0,true,true);
+    if ($um->process_file_uploads("$course->id/$CFG->moddata/wiki/$wiki->id/$entry->id/$ewiki_title")) {
+        $filename = ''; // this to make sure we don't keep processing in the parent function
+        if(!$id) {
+            $newfilename = $um->get_new_filename();
+            $id = EWIKI_IDF_INTERNAL.$newfilename;
         }
+        return true;
     }
+    error($um->print_upload_log(true));
     return false;
-      
-                   
-/*   if (($meta["size"] >= EWIKI_DB_STORE_MINSIZE) && ($meta["size"] <= EWIKI_DB_STORE_MAXSIZE)) {
-
-      #-- generate internal://md5sum
-      if (empty($id)) {
-         $md5sum = md5_file($filename);
-         $id = EWIKI_IDF_INTERNAL . $md5sum . ".$ext";
-         ewiki_log("generated md5sum '$md5sum' from file content");
-      }
-
-      #-- move file to dest. location
-      $dbfname = EWIKI_DB_STORE_DIRECTORY."/".rawurlencode($id);
-      if (@rename($filename, $dbfname) || copy($filename, $dbfname) && unlink($filename)) {
-         $filename = "";
-         $meta["binary_store"] = 1;
-         return(true);
-      }
-      else {
-         ewiki_log("file store error with '$dbfname'", 0);
-      }
-   }
-
-   return(false);*/
+   
 }