changeset 211:5bae42020034

Factorize some code into msitegen.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 17 Nov 2013 20:51:03 +0200
parents cafc05949a19
children 4cee86b4e0b7
files admajax.php msitegen.inc.php showajax.php usrajax.php
diffstat 4 files changed, 26 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Sun Nov 17 20:35:52 2013 +0200
+++ b/admajax.php	Sun Nov 17 20:51:03 2013 +0200
@@ -505,20 +505,5 @@
     break;
 }
 
-if ($errorSet && !$statusSet)
-  stSetStatus(902, "Error");
-
-if ($statusSet)
-{
-  http_response_code($statusSet);
-  header("Status: ".$statusSet." ".$statusMsg);
-}
-  
-if ($errorSet)
-{
-  echo "Following errors occured:\n";
-  foreach ($errorMsgs as $msg)
-    echo " - ".$msg."\n";
-}
-
+stDumpAJAXStatusErrors();
 ?>
\ No newline at end of file
--- a/msitegen.inc.php	Sun Nov 17 20:35:52 2013 +0200
+++ b/msitegen.inc.php	Sun Nov 17 20:51:03 2013 +0200
@@ -48,6 +48,28 @@
 }
 
 
+function stDumpAJAXStatusErrors()
+{
+  global $errorSet, $errorMsgs, $statusSet, $statusMsg;
+
+  if ($errorSet && !$statusSet)
+    stSetStatus(902, "Error");
+
+  if ($statusSet)
+  {
+    http_response_code($statusSet);
+    header("Status: ".$statusSet." ".$statusMsg);
+  }
+    
+  if ($errorSet)
+  {
+    echo "Following errors occured:\n";
+    foreach ($errorMsgs as $msg)
+      echo " - ".$msg."\n";
+  }
+}
+
+
 function stCheckHTTPS()
 {
   return isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != "" && $_SERVER["HTTPS"] != "off");
--- a/showajax.php	Sun Nov 17 20:35:52 2013 +0200
+++ b/showajax.php	Sun Nov 17 20:51:03 2013 +0200
@@ -170,7 +170,6 @@
     // Check if there has been any change
     $changed = stGetRequestItem("lastUpdate") != stGetDisplayVar("lastUpdate");
     echo $changed ? "changed" : "nochange";
-    stSetStatus(200, "OK");
     break;
 
   case "get":
@@ -230,4 +229,6 @@
 
 // Save changed variables
 stSaveDisplayVars();
+
+stDumpAJAXStatusErrors();
 ?>
\ No newline at end of file
--- a/usrajax.php	Sun Nov 17 20:35:52 2013 +0200
+++ b/usrajax.php	Sun Nov 17 20:51:03 2013 +0200
@@ -132,4 +132,5 @@
     break;
 }
 
+stDumpAJAXStatusErrors();
 ?>
\ No newline at end of file