fix chech rights on startup
This commit is contained in:
@@ -1,12 +1,19 @@
|
||||
# MEMORY.md - Stato del Plugin UrBackup
|
||||
|
||||
## Ultima modifica: 25/08/2026
|
||||
## Ultima modifica: 31/08/2026
|
||||
|
||||
## 31/08/2026 — Fix campi API username/password non editabili in prod (solo UI)
|
||||
- **Sintomo utente**: installato il plugin sul server produttivo, nel form Server non si vede il campo API username e il campo API password è bloccato (asterischi fissi non editabili), anche per l'utente che ha installato il plugin.
|
||||
- **Causa**: divergenza nel controllo diritti. I front usavano `Profile::canCurrentUser()` (legge i diritti da `glpi_profilerights` su DB), ma `Server::showFormFields()` (form server) usava `Session::haveRight(self::$rightname, UPDATE)` per calcolare `$canEdit` (e idem `rawSearchOptions()` riga 308 e `showUnlinkedClientsTab()`/`showMissingClientsTab()` righe 1155/1222). `Session::haveRight` dipende dalla **cache dei diritti in sessione** (`$_SESSION['glpiactiveprofile']['rights']`), popolata al login. Dopo l'installazione/aggiornamento del plugin i diritti sono scritti in DB ma la **sessione corrente non viene ricostruita**, quindi `haveRight` resta false → ramo read-only: username stampato come testo (invisibile se vuoto), password `******` fissa.
|
||||
- **Fix**: sostituito `Session::haveRight(self::$rightname, ...)` con `Profile::canCurrentUser(...)` in Server.php (righe ~308, ~447-449, ~1155, ~1222) e AssetTab.php (riga ~446, tab Asset), coerente col resto del plugin, legge dal DB e aggira la cache di sessione stantia.
|
||||
- Nessun bump versione (nessuna modifica DB, regola 6); nessuna nuova stringa i18n.
|
||||
- Verifica IA: `php -l` OK; git diff autorevisione OK. **Verifica UI utente OBBLIGATORIA**: aggiornare il file su prod, poi testare il form Server (API username editabile + API password campo input con placeholder).
|
||||
|
||||
## 25/08/2026 — Blocco "This asset hosts the UrBackup server" in evidenza (solo UI)
|
||||
- **Richiesta utente**: mettere in evidenza con riquadro colorato il blocco host + nome del server UrBackup.
|
||||
- **Modifiche**: `AssetTab.php::showHostServerBlock()` — classi dedicate `plugin-urbackup-host-card` / `-card-header` sul card Bootstrap e `plugin-urbackup-host-server-link` sui link server; `public/css/urbackup.css` — card con bordo 2px #1e6091, header blu #1e6091 testo bianco, body #eaf3fa, link server bold 1.05rem.
|
||||
- Nessun bump versione (nessuna modifica DB, regola 6); nessuna nuova stringa i18n.
|
||||
- Verifiche IA: `php -l` OK; git diff autorevisione OK. Verifica visiva browser = **utente** (regola 7).
|
||||
- Verifiche IA: `php -l` OK; git diff autorevisione OK. **Verifica visiva browser: CONFERMATA dall'utente il 25/08/2026** ("ok funziona tutto").
|
||||
|
||||
## 07/08/2026 — Fix dropdown "Hardware host" (0.7.3): elemento non compariva
|
||||
- **Sintomo utente**: scelto il tipo host (es. Computer) nel form server, il dropdown degli elementi non compariva.
|
||||
@@ -28,7 +35,7 @@
|
||||
- **AssetTab.php**: `showHostServerBlock(CommonDBTM $item)` chiamata per prima in `displayTabContentForItem()` — card "This asset hosts the UrBackup server" con lista link (`Server::getFormURLWithID`) dai server che puntano all'asset; sempre visibile se c'è un host.
|
||||
- Locales: +2 msgid per lingua (182→184): `Hardware host` (it "Host hardware", de "Hardware-Host", en "Hardware host"), `This asset hosts the UrBackup server` (it "Questo asset ospita il server UrBackup", de "Dieses Asset hostet den UrBackup-Server", en identica); header .po → 0.7.3; `.mo` ricompilati (msgfmt --check OK, warning header pre-esistenti) + **cache traduzioni svuotata** (`files/_cache/*/translations/`).
|
||||
- **Verifiche IA**: `php -l` OK (setup.php, install/install.php, Server.php, AssetTab.php, dropdown_host.ajax.php); test CLI `/tmp/opencode/urbackup_host_test.php` 10/10 PASS (prepareInputForUpdate: host non inviato/items_id=0/itemtype vuoto/Monitor non abilitato/Computer valido/items_id inesistente; getHostAsset null; getServersHostingAsset SKIP in attesa migrazione).
|
||||
- **Stato attuale**: `glpi_plugins.version=0.7.3`, `state=1` (ACTIVE — update UI eseguito dall'utente il 07/08/2026, poi fix dropdown) → attende verifica visiva finale dell'utente.
|
||||
- **Stato attuale**: `glpi_plugins.version=0.7.3`, `state=1` (ACTIVE — update UI eseguito dall'utente il 07/08/2026, poi fix dropdown). **Verifica visiva checklist 0.7.3 CONFERMATA dall'utente il 25/08/2026** ("ok funziona tutto") — feature 0.7.3 CHIUSA.
|
||||
- **Checklist UI utente 0.7.3 (verifica finale)**: (1) *Admin → Server* → aprire un server → "Hardware host": tipo → elemento (dropdown selezionabile) → Salva; (2) ricaricare il server: link host sotto la riga; (3) aprire l'asset host → card "Questo asset ospita il server UrBackup" con link al server; (4) verificare traduzioni it_IT/DE ("Host hardware", "Questo asset ospita il server UrBackup"); (5) smoke HTTP dropdown: GET `front/dropdown_host.ajax.php?itemtype=Computer` (sessione) → 200 select; itemtype=Monitor → rifiutato; senza sessione → 302/403.
|
||||
- **Doc aggiornate**: README.md Changelog 0.7.3; GLPIDEV.md (schema v0.7.3 + caveat 21 con le API caveat dropdown lazy/IDOR + nota api_password cifrata); MEMORY.md (questo file).
|
||||
|
||||
|
||||
+1
-1
@@ -443,7 +443,7 @@ class AssetTab extends CommonDBTM
|
||||
): void {
|
||||
echo "<div class='plugin-urbackup-inner-tabs'>";
|
||||
|
||||
$canWrite = Session::haveRight(self::$rightname, UPDATE) || Session::haveRight(self::$rightname, CREATE);
|
||||
$canWrite = Profile::canCurrentUser(UPDATE) || Profile::canCurrentUser(CREATE);
|
||||
|
||||
echo '<ul class="nav nav-tabs" id="urbackupTabs" role="tablist">';
|
||||
echo '<li class="nav-item" role="presentation">';
|
||||
|
||||
+5
-5
@@ -305,7 +305,7 @@ class Server extends CommonDBTM
|
||||
'datatype' => 'datetime',
|
||||
];
|
||||
|
||||
if (Session::haveRight(self::$rightname, UPDATE)) {
|
||||
if (Profile::canCurrentUser(UPDATE)) {
|
||||
$tab[] = [
|
||||
'id' => 14,
|
||||
'table' => self::getTable(),
|
||||
@@ -445,8 +445,8 @@ class Server extends CommonDBTM
|
||||
echo "</tr>";
|
||||
|
||||
$canEdit = $ID > 0
|
||||
? Session::haveRight(self::$rightname, UPDATE)
|
||||
: Session::haveRight(self::$rightname, CREATE);
|
||||
? Profile::canCurrentUser(UPDATE)
|
||||
: Profile::canCurrentUser(CREATE);
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>" . htmlspecialchars(__('API username', 'urbackup')) . "</td>";
|
||||
@@ -1152,7 +1152,7 @@ class Server extends CommonDBTM
|
||||
}
|
||||
}
|
||||
|
||||
$canWrite = Session::haveRight(self::$rightname, UPDATE) || Session::haveRight(self::$rightname, CREATE);
|
||||
$canWrite = Profile::canCurrentUser(UPDATE) || Profile::canCurrentUser(CREATE);
|
||||
|
||||
echo '<table class="table table-striped table-hover">';
|
||||
echo '<thead>';
|
||||
@@ -1219,7 +1219,7 @@ class Server extends CommonDBTM
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$canWrite = Session::haveRight(self::$rightname, UPDATE) || Session::haveRight(self::$rightname, CREATE);
|
||||
$canWrite = Profile::canCurrentUser(UPDATE) || Profile::canCurrentUser(CREATE);
|
||||
|
||||
$apiStatus = (int) ($server->fields['last_api_status'] ?? 0);
|
||||
if ($apiStatus !== 1) {
|
||||
|
||||
Reference in New Issue
Block a user