diff --git a/front/asset.form.php b/front/asset.form.php index fe666f5..3cfabf9 100644 --- a/front/asset.form.php +++ b/front/asset.form.php @@ -1,5 +1,7 @@ delete('glpi_plugin_urbackup_serverassets', ['id' => (int) $link['id']]); - if ($result) { $item->getFromDB($items_id); Html::redirect($item->getLinkURL()); diff --git a/front/config.form.php b/front/config.form.php index db0bb8c..5041d4e 100644 --- a/front/config.form.php +++ b/front/config.form.php @@ -1,5 +1,7 @@ runFile() - * - schema evolution using Migration addField(), addKey(), executeMigration() - * - * ------------------------------------------------------------------------- */ use GlpiPlugin\Urbackup\Config; diff --git a/install/uninstall.php b/install/uninstall.php index 454285e..29ca564 100644 --- a/install/uninstall.php +++ b/install/uninstall.php @@ -1,12 +1,11 @@ initForm($ID, $options); $this->showFormHeader($options); - $this->showFormFields($ID); + $this->showFormFields($ID > 0 ? (int) $ID : null); $this->showFormButtons($options); return true; @@ -1339,7 +1341,7 @@ JAVASCRIPT; return $cache[$id]; } - private static function getAssetIp(string $itemtype, int $items_id): string + public static function getAssetIp(string $itemtype, int $items_id): string { global $DB; diff --git a/src/ServerAsset.php b/src/ServerAsset.php index 56eb4d8..de697f7 100644 --- a/src/ServerAsset.php +++ b/src/ServerAsset.php @@ -79,7 +79,6 @@ class ServerAsset extends CommonDBTM } $table = self::getTable(); - $date = $_SESSION['glpi_currenttime'] ?? date('Y-m-d H:i:s'); $existing = self::getLinkForAsset($itemtype, $items_id, false); @@ -88,10 +87,6 @@ class ServerAsset extends CommonDBTM $table, [ 'plugin_urbackup_servers_id' => $server_id, - 'client_name' => (string) ($item->fields['name'] ?? ''), - 'client_ip' => self::extractAssetIp($item), - 'is_active' => 1, - 'date_mod' => $date, ], [ 'id' => (int) $existing['id'], @@ -243,43 +238,40 @@ class ServerAsset extends CommonDBTM echo "
"; echo ""; - echo ""; + echo ""; echo ""; echo ""; echo ""; echo ""; - echo ""; - echo ""; echo ""; $iterator = $DB->request([ 'FROM' => self::getTable(), 'WHERE' => [ 'plugin_urbackup_servers_id' => (int) $item->fields['id'], - 'is_active' => 1, ], - 'ORDER' => 'client_name', ]); foreach ($iterator as $row) { - $asset_label = (string) $row['client_name']; $itemtype = (string) $row['itemtype']; $items_id = (int) $row['items_id']; + $asset_label = (string) $items_id; + $asset_ip = ''; + if (class_exists($itemtype)) { $asset = new $itemtype(); if ($asset instanceof CommonDBTM && $asset->getFromDB($items_id)) { $asset_label = $asset->getLink(); + $asset_ip = Server::getAssetIp($itemtype, $items_id); } } echo ""; echo ""; echo ""; - echo ""; - echo ""; - echo ""; + echo ""; echo ""; }
" . htmlspecialchars(__('Linked assets', 'urbackup')) . "
" . htmlspecialchars(__('Linked assets', 'urbackup')) . "
" . htmlspecialchars(__('Asset', 'urbackup')) . "" . htmlspecialchars(__('Type')) . "" . htmlspecialchars(__('IP address', 'urbackup')) . "" . htmlspecialchars(__('Last file backup', 'urbackup')) . "" . htmlspecialchars(__('Last image backup', 'urbackup')) . "
" . $asset_label . "" . htmlspecialchars($itemtype) . "" . htmlspecialchars((string) $row['client_ip']) . "" . htmlspecialchars((string) $row['last_file_backup']) . "" . htmlspecialchars((string) $row['last_image_backup']) . "" . htmlspecialchars($asset_ip ?: '-') . "