groups.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
  3. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
  4. // Создание новой группы
  5. if (getPOST("create") !== null) {
  6. $fname = trim(getPOST("newgroup", null, ''));
  7. if ($fname !== '') {
  8. $new_id = insert_record($db_link, "group_list", ['group_name' => $fname]);
  9. if ($new_id) {
  10. header("Location: editgroup.php?id=$new_id");
  11. exit;
  12. }
  13. }
  14. header("Location: " . $_SERVER["REQUEST_URI"]);
  15. exit;
  16. }
  17. // Удаление групп
  18. if (getPOST("remove") !== null) {
  19. $fgid = getPOST("fid", null, []);
  20. if (!empty($fgid) && is_array($fgid)) {
  21. foreach ($fgid as $val) {
  22. $val = trim($val);
  23. if ($val === '') continue;
  24. // Сброс привязки в user_auth
  25. update_records($db_link, "user_auth",
  26. "deleted = 0 AND filter_group_id = ?",
  27. ['filter_group_id' => 0, 'changed' => 1],
  28. [$val]
  29. );
  30. // Удаление связей
  31. delete_records($db_link, "group_filters", "group_id = ?", [$val]);
  32. // Удаление самой группы
  33. delete_records($db_link, "group_list", "id = ?", [$val]);
  34. }
  35. }
  36. header("Location: " . $_SERVER["REQUEST_URI"]);
  37. exit;
  38. }
  39. unset($_POST);
  40. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
  41. print_filters_submenu($page_url);
  42. ?>
  43. <div id="cont">
  44. <form name="def" action="groups.php" method="post">
  45. <table class="data">
  46. <tr align="center">
  47. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  48. <td><b>Id</b></td>
  49. <td width=200><b><?php echo WEB_cell_name; ?></b></td>
  50. <td ><b><?php echo WEB_submenu_filter_instance; ?></b></td>
  51. <td width=200><b><?php echo WEB_cell_description; ?></b></td>
  52. <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>"></td>
  53. </tr>
  54. <?php
  55. $groups = get_records_sql($db_link, 'SELECT * FROM group_list ORDER BY id');
  56. foreach ($groups as $row) {
  57. $filter_instance = get_record_sql($db_link,'SELECT * FROM filter_instances WHERE id=?', [ $row["instance_id"] ]);
  58. print "<tr align=center>\n";
  59. print "<td class=\"data\" style='padding:0'><input type=checkbox name=fid[] value=" . $row["id"] . "></td>\n";
  60. print "<td class=\"data\" ><input type=\"hidden\" name=\"" . $row["id"] . "\" value=" . $row["id"] . ">" . $row["id"] . "</td>\n";
  61. print "<td class=\"data\"><a href=editgroup.php?id=" . $row["id"] . ">" . $row["group_name"] . "</a></td>\n";
  62. print "<td class=\"data\">". $filter_instance["name"]."</td>\n";
  63. print "<td class=\"data\">" . $row["description"] . "</td>\n";
  64. print "<td></td></tr>";
  65. }
  66. ?>
  67. </table>
  68. <div>
  69. <?php echo WEB_cell_name; ?><input type=text name=newgroup value="Unknown">
  70. <input type="submit" name="create" value="<?php echo WEB_btn_add; ?>">
  71. </div>
  72. </form>
  73. <?php
  74. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.php");
  75. ?>