|
1 | 1 | <?php |
| 2 | + |
2 | 3 | /* |
3 | 4 | * @version $Id$ |
4 | 5 | ------------------------------------------------------------------------- |
|
27 | 28 | -------------------------------------------------------------------------- |
28 | 29 | */ |
29 | 30 |
|
30 | | - |
31 | 31 | use GlpiPlugin\Addressing\Filter; |
32 | 32 | use GlpiPlugin\Addressing\Ping_Equipment; |
33 | 33 | use GlpiPlugin\Addressing\ReserveIp; |
| 34 | +use function Safe\json_encode; |
34 | 35 |
|
35 | 36 | Session::checkRight('plugin_addressing', UPDATE); |
36 | 37 |
|
37 | 38 | Html::header_nocache(); |
38 | 39 | header("Content-Type: text/html; charset=UTF-8"); |
39 | 40 |
|
40 | | -if (isset($_POST['action']) && $_POST['action'] == 'viewFilter') { |
| 41 | +if (isset($_GET['action']) && $_GET['action'] == 'isName') { |
| 42 | + $item = new $_GET['type'](); |
| 43 | + $datas = $item->find(['name' => ['LIKE', $_GET['name']]]); |
| 44 | + if (count($datas) > 0) { |
| 45 | + echo json_encode(true); |
| 46 | + } else { |
| 47 | + echo json_encode(false); |
| 48 | + } |
| 49 | +} else if (isset($_POST['action']) && $_POST['action'] == 'viewFilter') { |
41 | 50 | if (isset($_POST['items_id']) |
42 | 51 | && isset($_POST["id"])) { |
43 | 52 | $filter = new Filter(); |
|
46 | 55 | echo __('Access denied'); |
47 | 56 | } |
48 | 57 | } elseif (isset($_POST['action']) && $_POST['action'] == 'entities_networkip') { |
| 58 | + |
49 | 59 | IPNetwork::showIPNetworkProperties($_POST['entities_id']); |
50 | 60 | } elseif (isset($_POST['action']) && $_POST['action'] == 'entities_location') { |
| 61 | + |
| 62 | + echo __('Location'); |
51 | 63 | Dropdown::show('Location', ['name' => "locations_id", |
52 | | - 'value' => $_POST["value"], |
53 | | - 'entity' => $_POST['entities_id']]); |
| 64 | + 'value' => $_POST["value"], |
| 65 | + 'entity' => $_POST['entities_id']]); |
54 | 66 | } elseif (isset($_POST['action']) && $_POST['action'] == 'entities_fqdn') { |
| 67 | + echo __('FQDN'); |
55 | 68 | Dropdown::show('FQDN', ['name' => "fqdns_id", |
56 | | - 'value' => $_POST["value"], |
57 | | - 'entity' => $_POST['entities_id']]); |
| 69 | + 'value' => $_POST["value"], |
| 70 | + 'entity' => $_POST['entities_id']]); |
58 | 71 | } elseif ($_GET['action'] == 'ping') { |
59 | 72 | Html::popHeader(__s('IP ping', 'addressing'), $_SERVER['PHP_SELF']); |
60 | 73 |
|
|
64 | 77 | } |
65 | 78 | Html::popFooter(); |
66 | 79 | } else { |
67 | | - Html::popHeader(__s('IP reservation', 'addressing'), $_SERVER['PHP_SELF']); |
| 80 | + Html::popHeader(ReserveIp::getTypeName()); |
68 | 81 |
|
69 | 82 | if (filter_var($_GET["ip"], FILTER_VALIDATE_IP)) { |
70 | 83 | $ReserveIp = new ReserveIp(); |
|
0 commit comments