changeset 821:f27dccdde8ef

Partially remove old filename stuff from entries. Still some vestiges remain, however.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 24 Nov 2014 22:42:17 +0200
parents e213dca6354d
children fc555d954b99
files admajax.php dbdefs.inc.php
diffstat 2 files changed, 17 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Mon Nov 24 22:31:47 2014 +0200
+++ b/admajax.php	Mon Nov 24 22:42:17 2014 +0200
@@ -82,10 +82,6 @@
         array(CHK_ISGT, VT_STR, 0, "Author name not set."),
         array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_AUTHOR, "Entry author too long (%1 chars, must be less than %2)."));
 
-      stChkRequestItemFail("filename", $fake, $res,
-        array(CHK_TYPE, VT_TEXT, "Invalid data."),
-        array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_FILENAME, "Entry filename too long (%1 chars, must be less than %2)."));
-
       stChkRequestItemFail("info", $fake, $res,
         array(CHK_TYPE, VT_TEXT, "Invalid data."),
         array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_INFO, "Entry info text too long (%1 chars, must be less than %2)."));
@@ -183,6 +179,11 @@
 }
 
 
+function stGetFileUploadAndSelector($mode, $prefix, $name, $entry, $what)
+{
+}
+
+
 function stPrintEntryItemData($item, $row, $tr, $prefix, $compo, $mode)
 {
   global $entryFlagsList, $previewTypeList, $compoModeData;
@@ -216,20 +217,8 @@
       "   ".stGetEditFormTextInput($mode, "Author", 20, SET_LEN_ENTRY_AUTHOR, "author", $eid, $prefix, $item["author"])."\n".
       "   </div>\n".
       "   <div class=\"entryCell entryFiles\">\n".
-      "   ".stGetEditFormTextInput($mode, "Scratch filename", 25, SET_LEN_ENTRY_FILENAME, "filename", $eid, $prefix, $item["filename"])."\n";
-      
-      switch ($mode)
-      {
-        case 0:
-          
-          break;
-
-        case 2:
-          echo "<div>Set above filename only if entry file not available. Otherwise, add entry, then upload.</div>";
-          break;
-      }
-      
-      echo
+      stGetFileUploadAndSelector($mode, $prefix, "entryFileUpload", $entry, "file_id").
+      stGetFileUploadAndSelector($mode, $prefix, "previewFileUpload", $entry, "preview_id").
       "   </div>\n".
       "   <div class=\"entryCell entryNotes\">\n".
       "    ".stGetEditFormTextArea($mode, "Info shown during compo", 2, 25, "info", $eid, $prefix, $item["info"])."\n".
@@ -1512,12 +1501,12 @@
             "name" => "",
             "author" => "",
             "compo_id" => $id,
-            "filename" => "",
             "info" => "",
             "notes" => "",
             "preview_type" => 0,
             "flags" => 0,
             "evalue" => 0,
+            "utime" => 0,
             ),
             0, TRUE, "ne", $compo, EEMODE_ADD);
 
@@ -1663,15 +1652,15 @@
         {
           case COMPO_NORMAL:
             $sql = stPrepareSQL(
-            "INSERT INTO entries (name,author,compo_id,filename,info,notes,preview_type) VALUES (%S,%S,%d,%S,%Q,%Q,%D)",
-            "name", "author", $compo["id"], "filename", "info", "notes", "preview_type");
+            "INSERT INTO entries (name,author,compo_id,info,notes,preview_type,utime,owner_id) VALUES (%S,%S,%d,%Q,%Q,%D,%d,0)",
+            "name", "author", $compo["id"], "info", "notes", "preview_type", time());
             break;
           
           case COMPO_POINTS:
           case COMPO_ASSIGN:
             $sql = stPrepareSQL(
-            "INSERT INTO entries (name,compo_id,notes,evalue) VALUES (%S,%d,%Q,%D)",
-            "name", $compo["id"], "notes", "evalue");
+            "INSERT INTO entries (name,compo_id,notes,evalue,utime,owner_id) VALUES (%S,%d,%Q,%D,%d,0)",
+            "name", $compo["id"], "notes", "evalue", time());
             break;
         }
         stExecSQLCond($sql, "OK, entry added.");
@@ -1783,7 +1772,6 @@
             case COMPO_NORMAL:
               $cdata = array(
                 "author" => "S",
-                "filename" => "S",
                 "info" => "Q",
                 "preview_type" => "D",
                 "compo_id" => "D",
--- a/dbdefs.inc.php	Mon Nov 24 22:31:47 2014 +0200
+++ b/dbdefs.inc.php	Mon Nov 24 22:42:17 2014 +0200
@@ -280,12 +280,15 @@
     array("name"         , "VARCHAR(".SET_LEN_ENTRY_NAME.")"),
     array("author"       , "VARCHAR(".SET_LEN_ENTRY_AUTHOR.")"),
     array("compo_id"     , "INT", "DEFAULT 0"),
-    array("filename"     , "VARCHAR(".SET_LEN_ENTRY_FILENAME.")", "DEFAULT NULL"),
     array("info"         , "VARCHAR(".SET_LEN_ENTRY_INFO.")", "DEFAULT NULL"),
     array("notes"        , "VARCHAR(".SET_LEN_ENTRY_NOTES.")", "DEFAULT NULL"),
-    array("preview_type" , "INT", "DEFAULT 0"),
     array("flags"        , "INT", "DEFAULT 0"),
     array("evalue"       , "INT", "DEFAULT 0"),
+    array("file_id"      , "INT", "DEFAULT 0"), // currently default file from "files" table
+    array("preview_type" , "INT", "DEFAULT 0"), // see EPREV_*, overrides compo's general type if != 0
+    array("utime"        , "INT", "DEFAULT 0"),
+    array("owner_id"     , "INT", "DEFAULT 0"), // 0 = admin, otherwise votekey id
+  ),
   ),
 
   "attendees" => array(