Upload via GUI (452 Dateien)

This commit is contained in:
2026-11-05 21:22:06 +00:00
parent ded90af175
commit 752b42245a
9 changed files with 584 additions and 0 deletions
@@ -0,0 +1,27 @@
<?php
/**
* tools/manual/install_plugins.php: installiert und aktiviert die mitgelieferten Plugins in der Demo-Installation (für die Bilder im Handbuch).
* php tools/manual/install_plugins.php <Demo-Ordner> <Ordner mit den Plugin-ZIPs>
*/
$tmp = rtrim(str_replace('\\', '/', $argv[1] ?? ''), '/');
$zips = rtrim(str_replace('\\', '/', $argv[2] ?? ''), '/');
if (!is_file("$tmp/includes/bootstrap.php") || !is_dir($zips)) { fwrite(STDERR, "Aufruf: install_plugins.php <Demo-Ordner> <Plugin-ZIPs>\n"); exit(1); }
putenv('DESKHUB_CATALOG_DEFAULTS=' . dirname(__DIR__, 2) . '/tests/fixtures/no-catalog.php');
chdir($tmp);
date_default_timezone_set('Europe/Berlin');
require_once "$tmp/includes/bootstrap.php";
$pdo = get_db();
$want = ['tagesbericht', 'schichtuebergabe', 'rundmail', 'spamfilter', 'virenscan', 'ueberwachung', 'datenschutz', 'vertretung', 'community-bot', 'authentik', 'nas-backup', 'virustotal', 'cache-manager', 'code-issue-sync', 'cloudflare-protection', 'lang-en'];
foreach ($want as $slug) {
$best = null;
foreach (glob("$zips/{$slug}-*.zip") ?: [] as $z) if ($best === null || version_compare(preg_replace('/^.*-(\d+\.\d+\.\d+)\.zip$/', '$1', basename($z)), preg_replace('/^.*-(\d+\.\d+\.\d+)\.zip$/', '$1', basename($best))) > 0) $best = $z;
if (!$best) { echo "übersprungen (kein ZIP): $slug\n"; continue; }
$r = plugin_install_zip($pdo, $best);
if (empty($r['ok'])) { echo "FEHLER $slug: " . json_encode($r, JSON_UNESCAPED_UNICODE) . "\n"; continue; }
$zip = new ZipArchive();
$zip->open($best);
$perms = [];
for ($i = 0; $i < $zip->numFiles; $i++) if (preg_match('#(^|/)plugin\.json$#', $zip->getNameIndex($i))) { $perms = (json_decode($zip->getFromIndex($i), true)['permissions'] ?? []); break; }
$a = plugin_set_active($pdo, $r['slug'], true, $perms);
echo ($a['ok'] ? 'aktiv ' : 'inaktiv ') . $r['slug'] . (empty($a['ok']) ? ' – ' . json_encode($a, JSON_UNESCAPED_UNICODE) : '') . "\n";
}