changeset 627:18f52c7daf77

Make group-specific settings updates possible.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 01 Nov 2014 06:38:26 +0200
parents abda11cd3259
children 914d57c80059
files admajax.php admin.php
diffstat 2 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Sat Nov 01 06:37:43 2014 +0200
+++ b/admajax.php	Sat Nov 01 06:38:26 2014 +0200
@@ -1456,20 +1456,20 @@
     //
     // Update existing entry
     //
-    if ($type == "settings")
-    {
-      stDBBeginTransaction();
-      foreach (stExecSQL("SELECT * FROM settings") as $item)
-      if (($val = stGetRequestItem($item["key"], FALSE)) !== FALSE)
-      {
-        $sql = "UPDATE settings SET ".stGetSettingSQL($item, $val)." WHERE key=".$db->quote($item["key"]);
-        stExecSQLCond($sql, "OK, setting updated.");
-      }
-      stDBCommitTransaction();
-    }
-    else
     if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data.")))
     {
+      if ($type == "settings")
+      {
+        stDBBeginTransaction();
+        foreach (stExecSQL("SELECT * FROM settings WHERE vgroup=".$id) as $item)
+        if (($val = stGetRequestItem($item["key"], FALSE)) !== FALSE)
+        {
+          $sql = "UPDATE settings SET ".stGetSettingSQL($item, $val)." WHERE key=".$db->quote($item["key"]);
+          stExecSQLCond($sql, "OK, setting updated.");
+        }
+        stDBCommitTransaction();
+      }
+      else
       if ($type == "attendees" && stValidateRequestUserData(TRUE))
       {
         $sql = stPrepareSQLUpdate("attendees",
--- a/admin.php	Sat Nov 01 06:37:43 2014 +0200
+++ b/admin.php	Sat Nov 01 06:38:26 2014 +0200
@@ -20,7 +20,7 @@
   foreach (stExecSQL("SELECT * FROM settings_groups") as $group)
   {
     $args = array();
-    if (($res = stExecSQL("SELECT * FROM settings")) !== FALSE)
+    if (($res = stExecSQL("SELECT * FROM settings WHERE vgroup=".$group["id"])) !== false)
     {
       foreach ($res as $item)
       {
@@ -42,7 +42,7 @@
   "\n".
   "function jsUpdateSettings(id)\n".
   "{\n".
-  "  jsSendPOSTRequest(\"action=update&type=settings&\"+jsSettingsArgs[id]);\n".
+  "  jsSendPOSTRequest(\"action=update&type=settings&id=\"+id+\"&\"+jsSettingsArgs[id]);\n".
   "  return false;\n".
   "}\n".
   "\n";