Files
xamxam/TODO.md
Pontoporeia 7c30d1c55d Fix relink: close modal + HTMX refresh for immediate pool update
- After relink, always close the modal (even if FilePond input not found,
  e.g. page refreshed by live-reload during the fetch).
- After closing, re-fetch #format-fichiers-block via HTMX from
  /admin/fragments/fichiers.php?_thesis_id=N which loads thesis files
  from DB and re-renders the fragment with pre-populated FilePond pools.
  The afterSwap handler auto-reinitializes FilePond instances.
- Updated admin/fragments/fichiers.php to accept _thesis_id, load
  existing files from DB, build per-queue-type JSON, and render in
  edit mode.
2026-05-19 01:32:34 +02:00

9.8 KiB

Current tasks

Deploy exclusions

  • Exclude storage/tmp/ (not just filepond/*) to skip _trash dirs with bad perms
  • Exclude storage/documents/ and storage/theses/ from rsync deploy

Commit history cleanup

  • Squash 177→98 commits by merging similar/iterative fixes and immediate follow-ups
  • Resolve 206k lines of nested jj conflict markers in acces.php
  • Update commit descriptions for squashed groups

acces.php conflict marker cleanup

  • Remove 206k lines of nested jj conflict markers from acces.php (resolved from clean nzllwsxo base)
  • Restore missing features: create-result dialog, locked_year field, auto-generated password UI, file restrictions section, admin TOC wrapper

Save fixes (files disappearing on edit/terminer)

  • Fix: note_intention deleted on save — handleFilePondSingleFile treats existing DB id as new upload, deletes existing, then can't re-process (integer vs hex mismatch)
  • Fix: cover removal now uses trash, same hex-vs-integer guard as note_intention
  • Fix: all file deletions now route through deleteThesisFileToTrash (renames to tmp/_trash instead of unlinking)

Storage restructure

  • Move storage root from theses/ to documents/ (ThesisFileHandler, ThesisEditController, ThesisCreateController, MediaController)
  • MediaController: support both theses/ and documents/ prefixes for visibility gate
  • Migration: rename existing theses/ directories to documents/ on disk and update DB paths
  • Backend: endpoint to browse documents/ directory (file-browser.php with HTMX tree)
  • Backend: endpoint to relink an existing file to a thesis (relink.php inserts thesis_files row)
  • Frontend: modal with folder browser, triggered by a "Relier" button next to each FilePond pool
  • JS: integrate relink button into FilePond UI (XamxamOpenFileBrowser + XamxamRelinkFile)
  • CSS: .relink-modal + .file-browser styles in form.css
  • Fix: relinked file not appearing in FilePond pool — add file metadata to addFile() options and extensive diag logging
  • Fix: addFile called with single object instead of (source, options) — FilePond API mismatch prevented files from loading
  • Fix: use type 'limbo' for relinked files so they go through DID_COMPLETE_ITEM_PROCESSING → onprocessfile → syncOrderInput + green checkmark visual
  • Fix: change .filepond--file default border from yellow to green (existing files never reach processing-complete state)
  • Migration: rename existing theses/ directories to documents/ on disk and update DB paths

Trash policy

  • FilePond remove moves to tmp/_trash (already implemented in handleRemove)

  • Fix: partage FilePond asks admin password — shared handler + separate partage endpoints with share_active session gate

  • Fix: mots-clé HTMX search — restored tag-search-fragment.php logic lost during fragment architecture refactor

  • Generalize pill-search: single fragment endpoint (type=tag|language|supervisor), deduplicate tag & language backends, add jury autocomplete (promoteur·ice interne/externe ULB, lecteur·ice interne/externe)

  • Deploy: just deploy (includes new partage/actions/filepond/ + FilepondHandler.php)

  • Fix: language pill-search showing mots-clé results — form field name collision; replaced hidden inputs with scoped hx-vals; fixed exclude logic per type

  • Add Créer button to jury supervisor autocomplete (removed guard in pill-search-fragment.php)

  • Fix: UNIQUE constraint on authors.email — findOrCreateAuthor now checks for existing author by email before inserting; prevents crash when two authors share an email

Current tasks

  • Mandatory auto-generated passwords on share links (no custom passwords, regenerate-only in edit, rate limit on password gate)
  • .gitignore / .ignore: exclude *.db-wal and *.db-shm
  • CSS: FilePond pool file block border yellow → green on upload complete
  • Move shared fichiers-fragment.php from partage/ to templates/partials/form/ and update all links
  • Remove Écriture and Image format types (migration 035 + schema seed + query filter)
  • FilePond image previews: use site light colors (--bg-secondary, --text-secondary, --accent-green, --error)
  • Edit mode: remove custom file preview list above FilePond pools; use FilePond pools for preexisting files
  • Cover + note_intention: add data-existing-files to their FilePond inputs (per-queue-type JSON arrays)
  • Remove upload-progress bar at bottom (FilePond handles its own progress)
  • Remove upload-progress.js from edit/add/partage page extraJs arrays

FilePond Refactor — Merge video/audio into TFE pool

  • A. fichiers-fragment.php — Remove separate video/audio pools, merge into TFE; include PeerTube in data-existing-files
  • B. file-upload-filepond.js — Remove peertube_video/peertube_audio/video/audio from QUEUE_CONFIG, remove acceptedFileTypesPeerTube, remove data-peertube-active logic
  • C. process.php — When queue_type=tfe and video/audio + PeerTube enabled, upload to PeerTube, return peertube:UUID
  • D. load.php — Handle peertube DB files: return placeholder SVG blob
  • E. form.php — Include PeerTube files in existingFilesJsonForTfe for edit mode
  • F. ThesisEditController.php — Remove separate video/audio/peertube_* handleFilePondQueueFiles calls; also legacy $_FILES path
  • G. ThesisCreateController.php — Same as F

HTMX Fragment Architecture Reorganization

  • Create shared templates _licence.php and _format-website.php in templates/partials/form/
  • Create src/FragmentRenderer.php helper
  • Create public/admin/fragments/ and public/partage/fragments/ subdirectories
  • Create thin fragment endpoint files (auth + data prep + render shared template)
  • Update all hx-post references in templates to point to new fragments/ paths
  • Update partage/index.php routing for new fragments
  • Keep old fragment files as thin delegates to new fragments/ for backward compat
  • Update nginx config for partage fragment PHP handling

Maintenance mode + partage fragment fix

  • bootstrap.php: add /partage as allowed path prefix in maintenance gate
  • SystemController.php: update maintenance detail message
  • admin/parametres.php: always-visible accessibility table (Normal vs Maintenance)
  • admin.css: .param-access-table styles (border-radius via overflow:hidden, green/secondary colours)
  • partage/index.php: fix fragment routing — $slug was 'fragments' but check used str_starts_with($slug, 'fragments/'), causing HTMX fragments to redirect to / (main page)
  • Deploy: just deploy + just deploy-nginx

File browser fixes

  • Fix: top-folder navigation regex doesn't match bare documents/theses (requires trailing slash)
  • Replace emoji icons (📁📄) with proper SVG icons (folder, pdf, file-archive, text-file)
  • Fix relink endpoint: always return JSON (even on errors), guard finfo class, add diagnostic logging
  • Fix JS relink error handler to parse JSON error responses

Previous items

  • Step 1 — Build 4 PHP endpoints (process.php, revert.php, load.php, remove.php)
  • Step 2 — Update ThesisFileHandler to accept file_ids instead of $_FILES
  • Step 3 — Update file-upload-filepond.js (async server model + all fixes)
  • Step 4 — Update templates (data-queue-type on all inputs, data-existing-files in edit)
  • Step 5 — Update upload-progress.js (new collectFileNames, pending-uploads guard)
  • Step 6 — QA / integration testing
  • Step 7 — Cleanup: remove transition flags, remove INPUT_ID_TO_TYPE

CSP & Deploy Fixes (May 2026)

  • Track vendor JS files in jj (they were moved to vendor/ but never jj file tracked)
  • Add script-src 'self' 'unsafe-inline' to main CSP header (public pages use inline scripts + onclick handlers)
  • Add storage/tmp/filepond/* to .gitignore + rsync exclude, with .gitkeep
  • Deploy: just deploy to sync vendor JS files + updated CSP + .gitkeep to server

improvements_postlaunch — Année verrouillable dans partage + correction ID

Implémentation

  • Database::runMigrations(): ALTER TABLE share_links ADD COLUMN locked_year INTEGER
  • app/storage/schema.sql: ajouter la colonne
  • ShareLink::create(): accepter et stocker locked_year
  • ShareLink::update(): accepter et stocker locked_year
  • findBySlug() retourne déjà SELECT *, donc locked_year remonte automatiquement

3. Admin UI — Dialog de création de lien

  • Ajouter champ "Année académique verrouillée" dans create-dialog (acces.php)
  • Ajouter champ dans edit-dialog (acces.php)

4. Admin UI — Liste des liens

  • Afficher colonne "Année" dans le tableau des liens (acces.php)

5. Admin actions (acces-etudiante.php)

  • Lire locked_year depuis $_POST dans action 'create' et 'update'
  • Passer au ShareLink model

6. Partage — Formulaire

  • partage/index.php (renderShareLinkForm): lire locked_year depuis le lien
  • fieldset-academic.php: quand $lockedYear est défini → hidden input + span "Année académique verrouillée : YYYY" + explication; quand null → comportement actuel
  • ThesisCreateController::validateAndSanitise(): respecter locked_year si présent dans POST (priorité sur $_POST['année'])

7. Admin edit.php — Forcer l'identifiant

  • Ajouter un champ "Identifiant" en lecture seule mais avec un bouton "Regénérer"
  • ThesisEditController: ajouter méthode regenerateIdentifier() qui reconstruit YYYY-NNN avec MAX+1 sur la nouvelle année
  • Database: méthode regenerateThesisIdentifier(int $thesisId, int $year) — met à jour identifier basé sur l'année dans un SELECT FOR UPDATE
  • Attention: renommer les dossiers de fichiers sur disque si l'identifiant change