]> git.mjollnir.org Git - moodle.git/commitdiff
Integration of new centralised upload code with wiki/wikifiles.php - this is the...
authormjollnir_ <mjollnir_>
Wed, 15 Sep 2004 22:07:27 +0000 (22:07 +0000)
committermjollnir_ <mjollnir_>
Wed, 15 Sep 2004 22:07:27 +0000 (22:07 +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-63
    2004-09-15 21:56:38 GMT
    Penny Leach <penny@catalyst.net.nz>
    wikifiles integration with upload class - this is just the initial page part, not the upload a file into the wiki parg

Full logs:

Revision: moodle--eduforge--1.3.3--patch-63
Archive: arch-eduforge@catalyst.net.nz--2004
Creator: Penny Leach <penny@catalyst.net.nz>
Date: Thu Sep 16 09:56:38 NZST 2004
Standard-date: 2004-09-15 21:56:38 GMT
Modified-files: mod/wiki/wikifiles.php
New-patches: arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-63
Summary: wikifiles integration with upload class - this is just the initial page part, not the upload a file into the wiki parg
Keywords:

mod/wiki/wikifiles.php

index fe45d214fc9aa182f91738c4c1975abe6a30c0b9..bd8a4c31e0484fcb2435d4bd947f509461dfc866 100755 (executable)
 
         case "upload":
             html_header($course, $wdir);
-
-            if (!empty($_FILES['userfile'])) {
-                $userfile = $_FILES['userfile'];
-            } else {
-                $save = false;
-            }
+            require_once($CFG->dirroot.'/lib/uploadlib.php');
+                
             if (!empty($save)) {
-                if (!is_uploaded_file($userfile['tmp_name']) or $userfile['size'] == 0) {
-                    notify(get_string("uploadnofilefound"));
-                } else {
-                    $userfile_name = clean_filename($userfile['name']);
-                    if ($userfile_name) {
-                        $newfile = "$basedir$wdir/$userfile_name";
-                        if (move_uploaded_file($userfile['tmp_name'], $newfile)) {
-                            chmod($newfile, 0666);
-                            $a = NULL;
-                            $a->file = "$userfile_name (".$userfile['type'].")";
-                            $a->directory = $wdir;
-                            print_string("uploadedfileto", "", $a);
-                        } else {
-                            notify(get_string("uploadproblem", "", $userfile_name));
-                        }
-                    }
+                $um = new upload_manager('userfile',false,false,$course,false,0);
+                $dir = "$basedir$wdir";
+                if ($um->process_file_uploads($dir)) {
+                    notify(get_string('uploadedfile'));
                 }
+                // um will take care of error reporting.
                 displaydir($wdir);
-                    
             } else {
                 $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes);
                 $filesize = display_size($upload_max_filesize);
                 echo "<P>$struploadafile ($strmaxsize) --> <B>$wdir</B>";
                 echo "<TABLE><TR><TD COLSPAN=2>";
                 echo "<FORM ENCTYPE=\"multipart/form-data\" METHOD=\"post\" ACTION=\"".$ME."\">";
-                echo " <INPUT TYPE=hidden NAME=MAX_FILE_SIZE value=\"$upload_max_filesize\" />";
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id />";
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir />";
                 echo " <INPUT TYPE=hidden NAME=action VALUE=upload />";
-                echo " <INPUT NAME=\"userfile\" TYPE=\"file\" size=\"60\" />";
+                upload_print_form_fragment(1,array('userfile'),null,false,null,$course->maxbytes,0,false);
                 echo " </TD><TR><TD WIDTH=10>";
                 echo " <INPUT TYPE=submit NAME=save VALUE=\"$struploadthisfile\" />";
                 echo "</FORM>";