فهرست منبع

bugfix: fixed edit group rules

Roman Dmitriev 1 سال پیش
والد
کامیت
3388ae4
2فایلهای تغییر یافته به همراه22 افزوده شده و 15 حذف شده
  1. 18 12
      html/admin/filters/instances.php
  2. 4 3
      html/admin/groups/edit_group.php

+ 18 - 12
html/admin/filters/instances.php

@@ -3,12 +3,17 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 
 if (isset($_POST['save'])) {
-    $len = is_array($_POST['r_id']) ? count($_POST['r_id']) : 0;
+    $len = is_array($_POST['f_id']) ? count($_POST['f_id']) : 0;
     for ($i = 0; $i < $len; $i ++) {
-        $id = intval($_POST['r_id'][$i]);
-        $new['name'] = trim($_POST['f_name'][$i]);
-        $new['comment'] = trim($_POST['f_comment'][$i]);
-        update_record($db_link, "filter_instances", "id='$id'", $new);
+        $save_id = intval($_POST['f_id'][$i]);
+        $len_all = is_array($_POST['r_id']) ? count($_POST['r_id']) : 0;
+        for ($j = 0; $j < $len_all; $j ++) {
+            if (intval($_POST['r_id'][$j]) != $save_id) { continue; }
+            $id = intval($_POST['r_id'][$j]);
+            $new['name'] = trim($_POST['f_name'][$j]);
+            $new['comment'] = trim($_POST['f_comment'][$j]);
+            update_record($db_link, "filter_instances", "id='$id'", $new);
+        }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
@@ -54,17 +59,18 @@ print_filters_submenu($page_url);
 	<td><b><?php echo WEB_group_instance_name; ?></b></td>
 	<td><b><?php echo WEB_cell_comment; ?></b></td>
 	<td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
+        <?php print "<td><input type=\"submit\" name=\"save\" value='".WEB_btn_save."'></td>"; ?>
 </tr>
 <?php
 $t_instance=get_records_sql($db_link, "SELECT * FROM filter_instances");
 foreach ($t_instance as $row) {
-    print "<tr align=center>\n";
-    print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='".$row['id']."'></td>\n";
-    print "<td class=\"data\"><input type=\"hidden\" name='r_id[]' value='".$row['id']."'>".$row['id']."</td>\n";
-    print "<td class=\"data\"><input type=\"text\" name='f_name[]' value='".$row['name']."'></td>\n";
-    print "<td class=\"data\"><input type=\"text\" name='f_comment[]' value='".$row['comment']."'></td>\n";
-    print "<td class=\"data\"><input type=\"submit\" name=\"save\" value='".WEB_btn_save."'></td>\n";
-    print "</tr>\n";
+    print "<tr align=center>";
+    print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='".$row['id']."'></td>";
+    print "<td class=\"data\"><input type=\"hidden\" name='r_id[]' value='".$row['id']."'>".$row['id']."</td>";
+    print "<td class=\"data\"><input type=\"text\" name='f_name[]' value='".$row['name']."'></td>";
+    print "<td class=\"data\"><input type=\"text\" name='f_comment[]' value='".$row['comment']."'></td>";
+    print "<td colspan=2 class=\"data\"></td>";
+    print "</tr>";
 }
 ?>
 </table>

+ 4 - 3
html/admin/groups/edit_group.php

@@ -36,9 +36,9 @@ if (isset($_POST["s_remove"])) {
 }
 
 if (isset($_POST['s_save'])) {
-    $len = is_array($_POST['s_save']) ? count($_POST['s_save']) : 0;
+    $len = is_array($_POST['s_id']) ? count($_POST['s_id']) : 0;
     for ($i = 0; $i < $len; $i ++) {
-        $save_id = intval($_POST['s_save'][$i]);
+        $save_id = intval($_POST['s_id'][$i]);
         $len_all = is_array($_POST['n_id']) ? count($_POST['n_id']) : 0;
         for ($j = 0; $j < $len_all; $j ++) {
             if (intval($_POST['n_id'][$j]) != $save_id) { continue; }
@@ -129,6 +129,7 @@ if (!$ou_info['dynamic']) { print "disabled"; }; print " style=\"width:35%;\" ><
     <td><b><?php echo WEB_ou_rule; ?></b></td>
     <td><b><?php echo WEB_cell_comment; ?></b></td>
     <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="s_remove" value="<?php echo WEB_btn_delete; ?>"></td>
+    <?php print "<td><button id='s_save' name='s_save'>".WEB_btn_save."</button></td>"; ?>
 </tr>
 <?php
 $t_auth_rules = get_records($db_link,'auth_rules',"ou_id=$id ORDER BY id");
@@ -139,7 +140,7 @@ foreach ( $t_auth_rules as $row ) {
     print "<td class=\"data\">"; print_qa_rule_select("s_type[]","{$row['type']}"); print "</td>\n";
     print "<td class=\"data\"><input type=\"text\" name='s_rule[]' value='{$row['rule']}'></td>\n";
     print "<td class=\"data\"><input type=\"text\" name='s_comment[]' value='{$row['comment']}'></td>\n";
-    print "<td class=\"data\"><button id='s_save' name='s_save' value='{$row['id']}'>".WEB_btn_save."</button></td>\n";
+    print "<td colspan=2 class=\"data\"></td>\n";
     print "</tr>\n";
 }
 ?>