From e8c0ae7902082ed17837e92782a62db2705c4ca7 Mon Sep 17 00:00:00 2001 From: Amit Shanker Date: Fri, 9 Jul 2010 15:03:22 +0000 Subject: [PATCH] [GSOC-FUQT] Advanced File Uploader: Adding default values for the advanced settings for fuqt. Dev: fixed preview for fuqt git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@8914 b72ed6b6-b9f8-46b5-92b4-906544132732 --- common.php | 8 ++++++-- group.php | 2 +- index.php | 2 +- qanda.php | 17 ++++++++++++----- upload.php | 3 +++ uploader.php | 5 ++++- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/common.php b/common.php index 23d60ccceea..fcaca2a4a4e 100644 --- a/common.php +++ b/common.php @@ -4225,14 +4225,16 @@ function questionAttributes($returnByName=false) 'category'=>$clang->gT('Other'), 'sortorder'=>124, "inputtype"=>"integer", + 'default'=>10240, "help"=>$clang->gT("The surveyee cannot upload a single file larger than this size"), - "caption"=>$clang->gT("Maximum file size allowed")); + "caption"=>$clang->gT("Maximum file size allowed (in KB)")); $qattributes["max_num_of_files"]=array( "types"=>"|", 'category'=>$clang->gT('Other'), 'sortorder'=>126, "inputtype"=>"integer", + 'default'=>1, "help"=>$clang->gT("Maximum number of files that the surveyee can upload for this question"), "caption"=>$clang->gT("Max number of files")); @@ -4241,6 +4243,7 @@ function questionAttributes($returnByName=false) 'category'=>$clang->gT('Other'), 'sortorder'=>128, "inputtype"=>"integer", + 'default'=>0, "help"=>$clang->gT("Minimum number of files that the surveyee must upload for this question"), "caption"=>$clang->gT("Min number of files")); @@ -4249,8 +4252,9 @@ function questionAttributes($returnByName=false) 'category'=>$clang->gT('Other'), 'sortorder'=>130, "inputtype"=>"textarea", + 'default'=>"png, gif, doc, odt", "help"=>$clang->gT("Allowed file types in comma separated format. e.g. pdf, doc, odt"), - "caption"=>$clang->gT("Allowed file types")); + "caption"=>$clang->gT("Allowed file types (eg: pdf, doc, odt)")); //This builds a more useful array (don't modify) diff --git a/group.php b/group.php index dbf8950abc2..6b72c345a04 100644 --- a/group.php +++ b/group.php @@ -415,7 +415,7 @@ $hiddenfieldnames=implode("|", $inputnames); -if ($upload_file) +if (isset($upload_file) && $upload_file) echo "
\n"; diff --git a/index.php b/index.php index 9881fb60d3b..a2a84fdcd89 100644 --- a/index.php +++ b/index.php @@ -778,7 +778,7 @@ if (isset($move) || isset($_POST['saveprompt'])) { require_once("save.php"); - + // RELOAD THE ANSWERS INCASE SOMEONE ELSE CHANGED THEM if ($thissurvey['active'] == "Y" && $thissurvey['allowsave'] == "Y") { diff --git a/qanda.php b/qanda.php index dbe7eb76cf0..0878df0fc93 100644 --- a/qanda.php +++ b/qanda.php @@ -3505,7 +3505,7 @@ function do_file_upload($ia) "; - $answer .= "Open Uploader
"; + $currentdir = getcwd(); + $pos = stripos($currentdir, "admin"); + + if ($pos) + $answer .= "Upload files


"; + else + $answer .= "

Upload files




"; + $answer .= ""; $answer .= ""; - + /* $answer = ' @@ -3551,7 +3558,7 @@ function copyJSON(jsonstring, filecount) { '; - + for ($i = 1; $i <= $maxfiles; $i++) { $answer .= '' .''; - } + } */ // --> END NEW FEATURE - SAVE diff --git a/upload.php b/upload.php index 92549fe9b68..e653d7a6c98 100644 --- a/upload.php +++ b/upload.php @@ -5,6 +5,7 @@ $size=$_FILES['uploadfile']['size']; $valid_extensions = $_POST['valid_extensions']; $maxfilesize = $_POST['maxfilesize']; + $preview = $_POST['preview']; $valid_extensions_array = explode(",", $valid_extensions); @@ -45,6 +46,8 @@ "ext" => $ext, "msg" => "The file has been successfuly uploaded" ); + if ($preview == 0) + unlink($_FILES['uploadfile']['tmp_name']); echo json_encode($return); } // if there was some error, report error message diff --git a/uploader.php b/uploader.php index 61b83e4a3a6..d7bed9ad9b7 100644 --- a/uploader.php +++ b/uploader.php @@ -117,7 +117,8 @@ name: 'uploadfile', data: { valid_extensions : $('#allowed_filetypes').val(), - maxfilesize : $('#maxfilesize').val() + maxfilesize : $('#maxfilesize').val(), + preview : $('#preview').val() }, onSubmit : function(file, ext){ @@ -312,11 +313,13 @@ function addNotice(notice) { +
Upload
+

You can upload under KB each

   
@@ -3572,7 +3579,7 @@ function copyJSON(jsonstring, filecount) { .$clang->gT("Answer").'" >