mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
feat: dual upload system — direct file storage + PeerTube API integration
Adds a parallel PeerTube upload system behind a feature flag (disabled by default until upload quota is granted). When disabled, the existing direct file upload path works unchanged. Files: - src/PeerTubeService.php — credential storage (encrypted), OAuth2 token retrieval, multipart upload to /api/v1/videos/upload - migrations/021_peertube_settings.sql — peertube_settings singleton table + peertube_upload_enabled site_setting (default 0) - admin/actions/settings.php — peertube section handler - admin/parametres.php / templates/admin/parametres.php — PeerTube UI section - partage/fichiers-fragment.php — shows file inputs when enabled, TODO notice otherwise - ThesisCreateController / ThesisEditController — handlePeerTubeUpload() - tfe.php — PeerTube iframe embed detection - AdminLogger — logPeerTubeUpdate()
This commit is contained in:
@@ -12,6 +12,7 @@ if (!isset($_POST['csrf_token'], $_SESSION['csrf_token'])
|
||||
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/SmtpRelay.php';
|
||||
require_once APP_ROOT . '/src/PeerTubeService.php';
|
||||
require_once APP_ROOT . '/src/AdminLogger.php';
|
||||
$db = new Database();
|
||||
$logger = AdminLogger::make();
|
||||
@@ -70,6 +71,25 @@ if ($section === 'formulaire') {
|
||||
$_SESSION['_flash_smtp_field'] = $test['field'];
|
||||
}
|
||||
}
|
||||
} elseif ($section === 'peertube') {
|
||||
// Feature flag
|
||||
$enabled = isset($_POST['peertube_upload_enabled']) ? '1' : '0';
|
||||
$db->setSetting('peertube_upload_enabled', $enabled);
|
||||
|
||||
// Credentials — only overwrite password when user typed something
|
||||
$data = [
|
||||
'instance_url' => $_POST['peertube_instance_url'] ?? '',
|
||||
'username' => $_POST['peertube_username'] ?? '',
|
||||
'channel_id' => $_POST['peertube_channel_id'] ?? 1,
|
||||
'privacy' => $_POST['peertube_privacy'] ?? 1,
|
||||
];
|
||||
$pwd = $_POST['peertube_password'] ?? '';
|
||||
if ($pwd !== '') {
|
||||
$data['password'] = $pwd;
|
||||
}
|
||||
PeerTubeService::updateSettings($db, $data);
|
||||
$logger->logPeerTubeUpdate($enabled === '1');
|
||||
App::flash('success', 'Paramètres PeerTube mis à jour.');
|
||||
} else {
|
||||
App::flash('error', "Section inconnue.");
|
||||
}
|
||||
|
||||
@@ -10,8 +10,12 @@ $maintenanceOn = file_exists(APP_ROOT . '/storage/maintenance.flag');
|
||||
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/SmtpRelay.php';
|
||||
require_once APP_ROOT . '/src/PeerTubeService.php';
|
||||
$db = new Database();
|
||||
$siteSettings = $db->getAllSettings();
|
||||
$peerTubeSettings = PeerTubeService::getSettings($db);
|
||||
$peerTubeEnabled = PeerTubeService::isEnabled($db);
|
||||
$peerTubeConfigured = PeerTubeService::isConfigured($db);
|
||||
$stats = $db->getThesesStats();
|
||||
$smtpSettings = SmtpRelay::getSettings($db);
|
||||
$smtpConfigured = SmtpRelay::isConfigured($db);
|
||||
|
||||
@@ -24,7 +24,11 @@
|
||||
* admin_mode — '1' for admin context (removes required attrs)
|
||||
*/
|
||||
|
||||
$db = Database::getInstance()->getConnection();
|
||||
require_once APP_ROOT . '/src/PeerTubeService.php';
|
||||
$_ptDb = Database::getInstance();
|
||||
$peerTubeEnabled = PeerTubeService::isEnabled($_ptDb);
|
||||
|
||||
$db = $_ptDb->getConnection();
|
||||
|
||||
// Load all format types in display order
|
||||
$allFormats = $db->query('SELECT id, name FROM format_types ORDER BY sort_order, id')
|
||||
@@ -167,9 +171,20 @@ $hxPost = $adminMode ? '/admin/fichiers-fragment.php' : '/partage/fichiers-fragm
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($hasVideo): ?>
|
||||
<!-- Vidéo — TODO: PeerTube -->
|
||||
<fieldset class="fichiers-format-extra" id="fichiers-video">
|
||||
<legend>Vidéo</legend>
|
||||
<?php if ($peerTubeEnabled): ?>
|
||||
<div class="admin-form-group">
|
||||
<label for="peertube_video">Fichier vidéo<?= !$adminMode ? ' <span class="asterisk">*</span>' : '' ?> :</label>
|
||||
<div class="admin-file-input">
|
||||
<input type="file" id="peertube_video" name="peertube_video"
|
||||
accept="video/mp4,video/webm,video/ogg,video/quicktime,.mp4,.webm,.ogv,.mov"
|
||||
<?= !$adminMode ? 'required' : '' ?>>
|
||||
<small>MP4, WebM ou MOV. La vidéo sera hébergée sur PeerTube et intégrée
|
||||
comme lecteur embarqué sur la page du TFE. Max 500 MB.</small>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="admin-form-group fichiers-todo-notice">
|
||||
<p>
|
||||
🚧 <strong>À venir :</strong> l'upload vidéo sera géré directement via l'API PeerTube.
|
||||
@@ -180,13 +195,25 @@ $hxPost = $adminMode ? '/admin/fichiers-fragment.php' : '/partage/fichiers-fragm
|
||||
En attendant, déposez votre vidéo dans le champ TFE ci-dessus (ZIP si besoin).
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($hasAudio): ?>
|
||||
<!-- Audio — TODO: PeerTube -->
|
||||
<fieldset class="fichiers-format-extra" id="fichiers-audio">
|
||||
<legend>Audio</legend>
|
||||
<?php if ($peerTubeEnabled): ?>
|
||||
<div class="admin-form-group">
|
||||
<label for="peertube_audio">Fichier audio<?= !$adminMode ? ' <span class="asterisk">*</span>' : '' ?> :</label>
|
||||
<div class="admin-file-input">
|
||||
<input type="file" id="peertube_audio" name="peertube_audio"
|
||||
accept="audio/mpeg,audio/ogg,audio/wav,audio/flac,audio/aac,audio/mp4,.mp3,.ogg,.oga,.wav,.flac,.aac,.m4a"
|
||||
<?= !$adminMode ? 'required' : '' ?>>
|
||||
<small>MP3, OGG, WAV, FLAC ou AAC. Le fichier sera hébergé sur PeerTube et intégré
|
||||
comme lecteur embarqué sur la page du TFE. Max 500 MB.</small>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="admin-form-group fichiers-todo-notice">
|
||||
<p>
|
||||
🚧 <strong>À venir :</strong> l'upload audio sera géré via l'API PeerTube.
|
||||
@@ -197,6 +224,7 @@ $hxPost = $adminMode ? '/admin/fichiers-fragment.php' : '/partage/fichiers-fragm
|
||||
En attendant, déposez votre fichier audio dans le champ TFE ci-dessus (ZIP si besoin).
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user