Quellcode durchsuchen

added setting of the 'permanent' flag from the list of users

root vor 1 Jahr
Ursprung
Commit
ed6c353

+ 2 - 8
html/admin/devices/index.php

@@ -11,14 +11,8 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 if (isset($_POST["remove_device"])) {
     $dev_ids = $_POST["fid"];
     foreach ($dev_ids as $key => $val) {
-        if ($val) {
-                unbind_ports($db_link, $val);
-                run_sql($db_link, "DELETE FROM connections WHERE device_id=".$val);
-                run_sql($db_link, "DELETE FROM device_l3_interfaces WHERE device_id=".$val);
-                run_sql($db_link, "DELETE FROM device_ports WHERE device_id=".$val);
-                delete_record($db_link, "devices", "id=".$val);
-                }
-            }
+        if ($val) { delete_device($db_link,$val); }
+        }
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
     }

+ 6 - 2
html/admin/users/index.php

@@ -80,6 +80,7 @@ if ($msg_error) {
         <tr><td><input type=checkbox class="putField" name="e_bind_mac" value='1'></td><td><?php print WEB_user_bind_mac."&nbsp";print_qa_select('a_bind_mac', 1);?></td></tr>
         <tr><td><input type=checkbox class="putField" name="e_bind_ip" value='1'></td><td><?php print WEB_user_bind_ip."&nbsp";print_qa_select('a_bind_ip', 1);?></td></tr>
         <tr><td><input type=checkbox class="putField" name="e_create_netdev" value='1'></td><td><?php print WEB_user_create_netdev."&nbsp";print_qa_select('a_create_netdev', 1);?></td></tr>
+        <tr><td><input type=checkbox class="putField" name="e_permanent" value='1'></td><td><?php print WEB_user_permanent."&nbsp";print_qa_select('a_permanent', 0);?></td></tr>
         </table>
         <input type="submit" name="submit" class="btn" value="<?php echo WEB_btn_apply; ?>">
     </form>
@@ -116,7 +117,7 @@ if ($page<1) { $page=1; }
 $start = ($page * $displayed) - $displayed;
 print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 
-$sSQL = "SELECT U.id, U.login, U.fio, O.ou_name, U.enabled, U.day_quota, U.month_quota, U.blocked FROM User_list U, OU O WHERE $filter ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
+$sSQL = "SELECT U.id, U.login, U.fio, O.ou_name, U.enabled, U.day_quota, U.month_quota, U.blocked, U.permanent FROM User_list U, OU O WHERE $filter ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
 
 ?>
 
@@ -156,7 +157,9 @@ foreach ($users as $row) {
     }
     print "<tr align=center>\n";
     print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";
-    print "<td class=\"$cl\">".$row['id']."</td>\n";
+    $cl_id = $cl;
+    if (!empty($row['permanent']) and $row['permanent'] == 1) { $cl_id = 'warn'; }
+    print "<td class=\"$cl_id\">".$row['id']."</td>\n";
     if (empty($row['login'])) { $row['login']=$row['id']; }
     print "<td class=\"$cl\" align=left><a href=edituser.php?id=".$row['id'].">" . $row['login'] . "</a></td>\n";
     print "<td class=\"$cl\">".$row['fio']."</td>\n";
@@ -185,6 +188,7 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 <td class="off"><?php echo WEB_color_user_disabled; ?></td>
 <td class="error"><?php echo WEB_color_user_blocked; ?></td>
 <td class="custom"><?php echo WEB_color_user_custom; ?></td>
+<td class="warn"><?php echo WEB_color_user_permanent; ?></td>
 </table>
 
 <script src="/js/remodal/remodal.min.js"></script>

+ 1 - 0
html/inc/languages/english.php

@@ -72,6 +72,7 @@ define("WEB_color_user_blocked","Blocked by traffic");
 define("WEB_color_device_description","Device Status");
 define("WEB_color_user_empty","Login is empty");
 define("WEB_color_user_custom","Customised");
+define("WEB_color_user_permanent","Permanent");
 
 /* device and port state */
 define("WEB_device_online","Online");

+ 1 - 0
html/inc/languages/russian.php

@@ -72,6 +72,7 @@ define("WEB_color_user_blocked","Блокировка по трафику");
 define("WEB_color_device_description","Состояние устройства");
 define("WEB_color_user_empty","Логин пуст");
 define("WEB_color_user_custom","Вариативно");
+define("WEB_color_user_permanent","Неудаляемый");
 
 /* device and port state */
 define("WEB_device_online","Online");

+ 9 - 0
html/utils/user_apply.php

@@ -46,6 +46,10 @@ if (isset($_POST["ApplyForAll"])) {
         $_POST["a_create_netdev"] = 0;
     }
 
+    if (empty($_POST["a_permanent"])) {
+        $_POST["a_permanent"] = 0;
+    }
+
     $a_enabled       = $_POST["a_enabled"] * 1;
     $a_dhcp          = $_POST["a_dhcp"] * 1;
     $a_dhcp_acl      = $_POST["a_dhcp_acl"];
@@ -55,6 +59,7 @@ if (isset($_POST["ApplyForAll"])) {
     $a_day           = $_POST["a_day_q"] * 1;
     $a_month         = $_POST["a_month_q"] * 1;
     $a_ou_id         = $_POST["a_new_ou"] * 1;
+    $a_permanent     = $_POST["a_permanent"] * 1;
 
     $a_bind_mac      = $_POST["a_bind_mac"] * 1;
     $a_bind_ip       = $_POST["a_bind_ip"] * 1;
@@ -98,6 +103,10 @@ if (isset($_POST["ApplyForAll"])) {
                 $auth['ou_id'] = $a_ou_id;
             }
 
+            if (isset($_POST["e_permanent"])) {
+                $user['permanent'] = $a_permanent;
+            }
+
             $login = get_record($db_link, "User_list", "id='$val'");
             $msg .= " For all ip user id: " . $val . " login: " . $login['login'] . " set: ";
             $msg .= get_diff_rec($db_link, "User_list", "id='$val'", $user, 1);