pluizia codice
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* UrBackup plugin for GLPI
|
||||
@@ -70,16 +72,8 @@ if (isset($_POST['disconnect'])) {
|
||||
Html::displayRightError();
|
||||
}
|
||||
|
||||
global $DB;
|
||||
|
||||
$link = ServerAsset::getLinkForAsset($itemtype, $items_id, false);
|
||||
$result = ServerAsset::disconnectAsset($itemtype, $items_id);
|
||||
|
||||
if ($link === null) {
|
||||
Html::displayValidationError(__('Asset is not linked to any server'));
|
||||
}
|
||||
|
||||
$result = $DB->delete('glpi_plugin_urbackup_serverassets', ['id' => (int) $link['id']]);
|
||||
|
||||
if ($result) {
|
||||
$item->getFromDB($items_id);
|
||||
Html::redirect($item->getLinkURL());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use GlpiPlugin\Urbackup\Config;
|
||||
use Html;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use GlpiPlugin\Urbackup\Profile;
|
||||
use GlpiPlugin\Urbackup\Server;
|
||||
use GlpiPlugin\Urbackup\ServerAsset;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use GlpiPlugin\Urbackup\Profile;
|
||||
use GlpiPlugin\Urbackup\Server;
|
||||
use Html;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* AJAX endpoint for testing UrBackup API
|
||||
*/
|
||||
|
||||
+2
-10
@@ -1,19 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* UrBackup plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Install/update process for GLPI 11.
|
||||
*
|
||||
* GLPI 11 Migration class does not expose createTable()/addTable().
|
||||
* Compatible GLPI plugin pattern:
|
||||
*
|
||||
* - initial schema creation from SQL file using $DB->runFile()
|
||||
* - schema evolution using Migration addField(), addKey(), executeMigration()
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
use GlpiPlugin\Urbackup\Config;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* UrBackup plugin for GLPI
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Uninstall process for GLPI 11.
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
use GlpiPlugin\Urbackup\Profile;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// Force OPcache to reload this file when accessed via web
|
||||
if (PHP_SAPI !== 'cli' && function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate(__FILE__, true);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* UrBackup plugin for GLPI
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* UrBackup plugin for GLPI
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* UrBackup plugin for GLPI
|
||||
@@ -327,7 +329,7 @@ class Server extends CommonDBTM
|
||||
|
||||
$this->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;
|
||||
|
||||
|
||||
+6
-14
@@ -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 "<div class='center'>";
|
||||
echo "<table class='tab_cadre_fixehov'>";
|
||||
echo "<tr><th colspan='5'>" . htmlspecialchars(__('Linked assets', 'urbackup')) . "</th></tr>";
|
||||
echo "<tr><th colspan='4'>" . htmlspecialchars(__('Linked assets', 'urbackup')) . "</th></tr>";
|
||||
echo "<tr>";
|
||||
echo "<th>" . htmlspecialchars(__('Asset', 'urbackup')) . "</th>";
|
||||
echo "<th>" . htmlspecialchars(__('Type')) . "</th>";
|
||||
echo "<th>" . htmlspecialchars(__('IP address', 'urbackup')) . "</th>";
|
||||
echo "<th>" . htmlspecialchars(__('Last file backup', 'urbackup')) . "</th>";
|
||||
echo "<th>" . htmlspecialchars(__('Last image backup', 'urbackup')) . "</th>";
|
||||
echo "</tr>";
|
||||
|
||||
$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 "<tr class='tab_bg_1'>";
|
||||
echo "<td>" . $asset_label . "</td>";
|
||||
echo "<td>" . htmlspecialchars($itemtype) . "</td>";
|
||||
echo "<td>" . htmlspecialchars((string) $row['client_ip']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars((string) $row['last_file_backup']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars((string) $row['last_image_backup']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($asset_ip ?: '-') . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user