diritti sistemati
This commit is contained in:
@@ -312,8 +312,11 @@ Il test del pulsante "Test API" continua a restituire 403 Forbidden quando acces
|
||||
- `prepareInputForUpdate()` normalizza anche valori vuoti
|
||||
|
||||
**File modificati**:
|
||||
- `src/Server.php`: `showFormFields()`, `showMissingClientsTab()`, `getCachedName()` fix, `getAssetGroupName()`, `getAssetIp()`, `getCachedLocationName()`, `prepareInputForAdd/Update` default fix, icona menu `ti-hard-drives`
|
||||
- `src/Server.php`: `showFormFields()`, `showMissingClientsTab()`, `getCachedName()` fix, `getAssetGroupName()`, `getAssetIp()`, `getCachedLocationName()`, `prepareInputForAdd/Update` default fix, icona `ti-cloud-up`
|
||||
- `front/server.form.php`: Tab laterali, tab hash JS, breadcrumb admin, navigazione server
|
||||
- `front/server.php`: Breadcrumb admin, rimosso pulsante "Add" manuale (GLPI lo genera)
|
||||
- `src/Profile.php`: Icona profilo `ti-hard-drives`
|
||||
- `src/AssetTab.php`: Icona tab asset `ti-hard-drives`
|
||||
- `front/server.php`: Breadcrumb admin, rimosso pulsante "Add" manuale
|
||||
- `src/Profile.php`: Icona `ti-cloud-up`
|
||||
- `src/AssetTab.php`: Icona `ti-cloud-up`
|
||||
- **Permessi**: `front/server.form.php` ora usa READ invece di UPDATE per accesso form; View search option + pulsanti Connect nascosti per READ; API username/password nascosti per READ
|
||||
- **i18n**: aggiunte 17 stringhe mancanti con dominio `urbackup` a tutti i file e .po/.mo (it, en, de)
|
||||
- **Bug fix**: ServerAsset colonne rimosse, asset.form.php usa disconnectAsset(), `declare(strict_types=1)` in 11 file
|
||||
|
||||
@@ -12,7 +12,7 @@ if (!defined('GLPI_ROOT')) {
|
||||
|
||||
include_once GLPI_ROOT . "/inc/includes.php";
|
||||
|
||||
if (!Profile::canCurrentUser(UPDATE)) {
|
||||
if (!Profile::canCurrentUser(READ)) {
|
||||
Html::displayRightError();
|
||||
}
|
||||
|
||||
|
||||
+6
-11
@@ -326,15 +326,19 @@ class AssetTab extends CommonDBTM
|
||||
): void {
|
||||
echo "<div class='plugin-urbackup-inner-tabs'>";
|
||||
|
||||
$canWrite = Session::haveRight(self::$rightname, UPDATE) || Session::haveRight(self::$rightname, CREATE);
|
||||
|
||||
echo '<ul class="nav nav-tabs" id="urbackupTabs">';
|
||||
echo '<li class="nav-item">';
|
||||
echo '<a class="nav-link active" id="state-tab" data-bs-toggle="tab" href="#state" role="tab">';
|
||||
echo htmlspecialchars(__('State', 'urbackup'));
|
||||
echo '</a></li>';
|
||||
if ($canWrite) {
|
||||
echo '<li class="nav-item">';
|
||||
echo '<a class="nav-link" id="actions-tab" data-bs-toggle="tab" href="#actions" role="tab">';
|
||||
echo htmlspecialchars(__('Actions', 'urbackup'));
|
||||
echo '</a></li>';
|
||||
}
|
||||
echo '<li class="nav-item">';
|
||||
echo '<a class="nav-link" id="logs-tab" data-bs-toggle="tab" href="#logs" role="tab">';
|
||||
echo htmlspecialchars(__('Info / Log', 'urbackup'));
|
||||
@@ -347,9 +351,11 @@ class AssetTab extends CommonDBTM
|
||||
self::showStateSection($server, $link, $api_data);
|
||||
echo '</div>';
|
||||
|
||||
if ($canWrite) {
|
||||
echo '<div class="tab-pane fade" id="actions" role="tabpanel">';
|
||||
self::showActionsSection($item, $server, $link, $api_data);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="tab-pane fade" id="logs" role="tabpanel">';
|
||||
self::showInfoLogSection($api_data);
|
||||
@@ -450,17 +456,6 @@ class AssetTab extends CommonDBTM
|
||||
echo "<table class='tab_cadre_fixe'>";
|
||||
echo "<tr><th colspan='2'>" . htmlspecialchars(__('Available actions', 'urbackup')) . "</th></tr>";
|
||||
|
||||
if (!Profile::canCurrentUser(UPDATE) && !Profile::canCurrentUser(CREATE)) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td colspan='2'>";
|
||||
echo htmlspecialchars(__('You do not have permission for UrBackup actions.', 'urbackup'));
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "</table>";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$api_data['client_found'] && Profile::canCurrentUser(CREATE)) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>" . htmlspecialchars(__('Create client in UrBackup', 'urbackup')) . "</td>";
|
||||
|
||||
@@ -297,6 +297,7 @@ class Server extends CommonDBTM
|
||||
'datatype' => 'datetime',
|
||||
];
|
||||
|
||||
if (Session::haveRight(self::$rightname, UPDATE)) {
|
||||
$tab[] = [
|
||||
'id' => 13,
|
||||
'table' => self::getTable(),
|
||||
@@ -306,6 +307,7 @@ class Server extends CommonDBTM
|
||||
'datatype' => 'raw',
|
||||
'searchtype' => 'view',
|
||||
];
|
||||
}
|
||||
|
||||
return $tab;
|
||||
}
|
||||
@@ -431,21 +433,31 @@ class Server extends CommonDBTM
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
|
||||
$canUpdate = Session::haveRight(self::$rightname, UPDATE);
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>" . htmlspecialchars(__('API username', 'urbackup')) . "</td>";
|
||||
echo "<td>";
|
||||
if ($canUpdate) {
|
||||
echo Html::input('api_username', [
|
||||
'value' => $this->fields['api_username'] ?? '',
|
||||
'size' => 40,
|
||||
'autocomplete' => 'off',
|
||||
]);
|
||||
} else {
|
||||
echo htmlspecialchars($this->fields['api_username'] ?? '');
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
echo "<td>" . htmlspecialchars(__('API password', 'urbackup')) . "</td>";
|
||||
echo "<td>";
|
||||
if ($canUpdate) {
|
||||
echo "<input type='password' name='api_password' value='" .
|
||||
htmlspecialchars((string) ($this->fields['api_password'] ?? '')) .
|
||||
"' autocomplete='new-password'>";
|
||||
} else {
|
||||
echo '******';
|
||||
}
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
|
||||
@@ -992,6 +1004,8 @@ class Server extends CommonDBTM
|
||||
}
|
||||
}
|
||||
|
||||
$canWrite = Session::haveRight(self::$rightname, UPDATE) || Session::haveRight(self::$rightname, CREATE);
|
||||
|
||||
echo '<table class="table table-striped table-hover">';
|
||||
echo '<thead>';
|
||||
echo '<tr>';
|
||||
@@ -1000,7 +1014,9 @@ class Server extends CommonDBTM
|
||||
echo '<th>' . htmlspecialchars(__('Status', 'urbackup')) . '</th>';
|
||||
echo '<th>' . htmlspecialchars(__('Last backup', 'urbackup')) . '</th>';
|
||||
echo '<th>' . htmlspecialchars(__('IP address', 'urbackup')) . '</th>';
|
||||
if ($canWrite) {
|
||||
echo '<th>' . htmlspecialchars(__('Actions', 'urbackup')) . '</th>';
|
||||
}
|
||||
echo '</tr>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
@@ -1025,6 +1041,7 @@ class Server extends CommonDBTM
|
||||
echo '<td>' . $statusHtml . '</td>';
|
||||
echo '<td>' . htmlspecialchars($lastBackup ?: '-') . '</td>';
|
||||
echo '<td>' . htmlspecialchars($clientIp ?: '-') . '</td>';
|
||||
if ($canWrite) {
|
||||
echo '<td>';
|
||||
if (isset($linkableAssets[$clientNameLower])) {
|
||||
$match = $linkableAssets[$clientNameLower];
|
||||
@@ -1042,6 +1059,7 @@ class Server extends CommonDBTM
|
||||
echo '<span class="text-muted">—</span>';
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
@@ -1053,6 +1071,8 @@ class Server extends CommonDBTM
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$canWrite = Session::haveRight(self::$rightname, UPDATE) || Session::haveRight(self::$rightname, CREATE);
|
||||
|
||||
$apiStatus = (int) ($server->fields['last_api_status'] ?? 0);
|
||||
if ($apiStatus !== 1) {
|
||||
echo '<div class="alert alert-warning">';
|
||||
@@ -1196,7 +1216,9 @@ class Server extends CommonDBTM
|
||||
echo '<th class="sortable" data-col="5">' . htmlspecialchars(State::getTypeName(1)) . ' <span class="sort-arrow"></span></th>';
|
||||
echo '<th class="sortable" data-col="6">' . htmlspecialchars(User::getTypeName(1)) . ' <span class="sort-arrow"></span></th>';
|
||||
echo '<th class="sortable" data-col="7">' . htmlspecialchars(Group::getTypeName(1)) . ' <span class="sort-arrow"></span></th>';
|
||||
if ($canWrite) {
|
||||
echo '<th data-col="8">' . htmlspecialchars(__('Actions', 'urbackup')) . '</th>';
|
||||
}
|
||||
echo '</tr></thead>';
|
||||
echo '<tbody>';
|
||||
|
||||
@@ -1222,6 +1244,7 @@ class Server extends CommonDBTM
|
||||
echo '<td>' . htmlspecialchars($asset['state']) . '</td>';
|
||||
echo '<td>' . htmlspecialchars($asset['user']) . '</td>';
|
||||
echo '<td>' . htmlspecialchars($asset['group']) . '</td>';
|
||||
if ($canWrite) {
|
||||
echo '<td>';
|
||||
echo '<form method="post" action="' . htmlspecialchars($formAction) . '" class="d-inline">';
|
||||
echo Html::hidden('_glpi_csrf_token', ['value' => Session::getNewCSRFToken()]);
|
||||
@@ -1233,6 +1256,7 @@ class Server extends CommonDBTM
|
||||
echo '</button>';
|
||||
Html::closeForm();
|
||||
echo '</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user