Wiki integration with upload class.
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/[email protected]/moodle--eduforge--1.3.3 Index of arch patches in this commit: [email protected]/moodle--eduforge--1.3.3--patch-363 Penny Leach <[email protected]> wiki integration with upload class. [email protected]/moodle--eduforge--1.3.3--patch-364 Penny Leach <[email protected]> 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: [email protected] Creator: Penny Leach <[email protected]> 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: [email protected]/moodle--eduforge--1.3.3--patch-363 Summary: wiki integration with upload class. Keywords: Revision: moodle--eduforge--1.3.3--patch-364 Archive: [email protected] Creator: Penny Leach <[email protected]> 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: [email protected]/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:
This commit is contained in:
@@ -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.'" />'
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user