changeset 789:24bbd1f89794

Add few new settings, bump database version.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 21 Nov 2014 08:05:27 +0200
parents da0ddfe1b704
children 7d7258904b02
files dbdefs.inc.php pages/noauthvote.inc.php pages/vote.inc.php usrajax.php
diffstat 4 files changed, 41 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/dbdefs.inc.php	Fri Nov 21 08:04:13 2014 +0200
+++ b/dbdefs.inc.php	Fri Nov 21 08:05:27 2014 +0200
@@ -1,6 +1,6 @@
 <?
 
-$dbVersion = 22;
+$dbVersion = 24;
 
 //
 // Site settings and defaults we put in
@@ -207,6 +207,19 @@
 ",
   "Message shown after successful voting"),
 
+    "votingDisabled" => array(VT_TEXT, "
+<h1>Sorry, voting disabled!</h1>
+<p>Voting functionality not available at this time.</p>
+",
+    "Error message for voting disabled"),
+
+    "voteAuthError" => array(VT_TEXT, "
+<h1>Not authenticated to vote</h1>
+<p>
+You are not authenticated currently. <a href=\"vote\">Try to login again.</a>
+</p>
+",
+    "Error message for vote auth failure"),
   ),
 );
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pages/noauthvote.inc.php	Fri Nov 21 08:05:27 2014 +0200
@@ -0,0 +1,13 @@
+<?
+//
+// FAPWeb - Simple Web-based Demoparty Management System
+// About page
+// (C) Copyright 2012-2014 Tecnic Software productions (TNSP)
+//
+
+if (!stChkSetting("allowVoting"))
+  echo stGetSetting("votingDisabled");
+else
+  echo stGetSetting("voteAuthError");
+
+?>
\ No newline at end of file
--- a/pages/vote.inc.php	Fri Nov 21 08:04:13 2014 +0200
+++ b/pages/vote.inc.php	Fri Nov 21 08:05:27 2014 +0200
@@ -19,11 +19,7 @@
 
 // Check if voting is enabled
 if (!stChkSetting("allowVoting"))
-{
-  echo
-  "<h1>Sorry, voting disabled!</h1>\n".
-  "<p>Voting functionality not available at this time.</p>\n";
-}
+  echo stGetSetting("votingDisabled");
 else
 if (!stUserSessionAuth(FALSE))
 {
@@ -120,6 +116,7 @@
     stGetFormStart("vote", "usrajax.php").
     " ".stGetFormHiddenInput("mode", "done")."\n".
     " ".stGetFormHiddenInput("action", "submit")."\n".
+    " ".stGetFormHiddenInput("onerror", "noauthvote")."\n".
     stGetVoteButton();
 
   foreach (stExecSQL("SELECT * FROM compos WHERE visible<>0 AND voting<>0") as $compo)
--- a/usrajax.php	Fri Nov 21 08:04:13 2014 +0200
+++ b/usrajax.php	Fri Nov 21 08:05:27 2014 +0200
@@ -55,9 +55,18 @@
 
   stSessionEnd(SESS_USER);
 
-  stError("You are not authenticated currently. Try to login again.");
-  stSetStatus(902, "Not authenticated.");
-  stDumpAJAXStatusErrors();
+  switch (stGetRequestItem("action"))
+  {
+    case "submit":
+      header("Location: ".stGetRequestItem("onerror", stGetSetting("defaultPage")));
+      break;
+
+    default:
+      stError("You are not authenticated currently. Try to login again.");
+      stSetStatus(902, "Not authenticated.");
+      stDumpAJAXStatusErrors(FALSE);
+      break;
+  }
   exit;
 }