changeset 1034:8fecb417e6a9

Reintroduce per-entry preview_type.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 20 Nov 2015 07:28:53 +0200
parents ed22a3a3027f
children d8b14f80a6f0
files admajax.php admin.js dbdefs.inc.php
diffstat 3 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Fri Nov 20 07:20:39 2015 +0200
+++ b/admajax.php	Fri Nov 20 07:28:53 2015 +0200
@@ -87,6 +87,13 @@
       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)."));
+
+      if ($full)
+      {
+        stChkRequestItemFail("preview_type", $fake, $res,
+          array(CHK_TYPE, VT_INT, "Invalid data."),
+          array(CHK_RANGE, VT_INT, array(EPREV_NONE, EPREV_AUDIO), "Invalid preview type value."));
+      }
       break;
     
     case COMPO_POINTS:
@@ -1594,6 +1601,7 @@
             "compo_id" => $id,
             "info" => "",
             "notes" => "",
+            "preview_type" => 0,
             "flags" => 0,
             "evalue" => "",
             "utime" => 0,
--- a/admin.js	Fri Nov 20 07:20:39 2015 +0200
+++ b/admin.js	Fri Nov 20 07:28:53 2015 +0200
@@ -470,7 +470,7 @@
 
 function updateEntry(cid, id, edit)
 {
-  var args = jsMakePostArgs({"name":1, "author":1, "filename":1, "info":1, "notes":1, "compo_id":4, "evalue":2}, "en", id, true);
+  var args = jsMakePostArgs({"name":1, "author":1, "filename":1, "info":1, "notes":1, "compo_id":4, "evalue":2, "preview_type":4}, "en", id, true);
   var has_id = "compo_id" in lastPostArgs;
   var compo_id = lastPostArgs["compo_id"];
 
--- a/dbdefs.inc.php	Fri Nov 20 07:20:39 2015 +0200
+++ b/dbdefs.inc.php	Fri Nov 20 07:28:53 2015 +0200
@@ -262,9 +262,8 @@
     array("visible"      , "INT", "DEFAULT 0"),
     array("voting"       , "INT", "DEFAULT 0"),
     
-    // Default preview type (see PREV_* in msite.inc.php)
-    // Global for the compo (entry-specific overrides if it is != PREV_NONE)
-    // Preview filename/path is determined internally
+    // Default preview type (see EFILE_* in msite.inc.php) for this compo.
+    // Global for the compo (entry-specific overrides if it is != EFILE_NONE)
     array("preview_type" , "INT", "DEFAULT 0"),
 
     array("show_authors" , "INT", "DEFAULT 0"),
@@ -287,6 +286,7 @@
     array("evalue"       , "INT", "DEFAULT 0"),
     array("file_id"      , "INT", "DEFAULT 0"), // uploaded file id from "files" table
     array("preview_id"   , "INT", "DEFAULT 0"), // uploaded preview file id from "files" table
+    array("preview_type" , "INT", "DEFAULT 0"), // see EFILE_*, overrides compo's general type if != 0
     array("utime"        , "INT", "DEFAULT 0"),
     array("owner_id"     , "INT", "DEFAULT 0"), // 0 = admin, otherwise votekey id
   ),