„Dokumente“ heißt jetzt „Downloads“
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m38s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m31s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m39s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m54s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m50s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 3m18s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 3m19s
CI / Build-Artefakte aktuell (pull_request) Successful in 55s
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m38s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m31s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m39s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m54s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m50s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 3m18s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 3m19s
CI / Build-Artefakte aktuell (pull_request) Successful in 55s
Der Name „Dokumente“ bleibt dem kommenden QM-Modul (QM-Dokumente und -Formulare) vorbehalten. - Plugin plugins-core/downloads (Inhaus\Plugins\Downloads), Adresse /downloads, Rechte downloads.*, Objekttyp download_folder, Block downloads.folder, Kachel downloads.favorites - Migration für bestehende Installationen: Tabellen und Spalten, Rechte, Sichtbarkeiten, Menü, Startseiten-Anordnung, Blöcke in Seiten und Fassungen, Plugin-Zustand; mit Test - Alte Links unter /dokumente leiten dauerhaft weiter Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c71131d054
commit
f78cc96be7
120 changed files with 1091 additions and 866 deletions
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('download_folders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('parent_id')->nullable()->constrained('download_folders')->restrictOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('description', 500)->nullable();
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['parent_id', 'sort']);
|
||||
});
|
||||
|
||||
Schema::create('downloads', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('folder_id')->constrained('download_folders')->restrictOnDelete();
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
// Aktuelle Fassung; ältere bleiben in download_versions abrufbar.
|
||||
$table->unsignedBigInteger('current_version_id')->nullable();
|
||||
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['folder_id', 'title']);
|
||||
});
|
||||
|
||||
Schema::create('download_versions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('download_id')->constrained('downloads')->cascadeOnDelete();
|
||||
$table->unsignedInteger('version');
|
||||
$table->string('name');
|
||||
$table->string('path');
|
||||
$table->string('mime', 150)->nullable();
|
||||
$table->unsignedBigInteger('size')->default(0);
|
||||
$table->string('note', 500)->nullable();
|
||||
$table->foreignId('uploaded_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
|
||||
$table->unique(['download_id', 'version']);
|
||||
$table->index('name');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('download_versions');
|
||||
Schema::dropIfExists('downloads');
|
||||
Schema::dropIfExists('download_folders');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
use App\Plugins\PluginState;
|
||||
use App\Support\Permissions\Permissions;
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Aus dem Modul „Dokumente“ wird „Downloads“ (der Name „Dokumente“ bleibt dem
|
||||
* QM-Modul vorbehalten). Bestehende Installationen: Tabellen, Rechte, Sichtbarkeiten,
|
||||
* Einstellungen, Pagebuilder-Blöcke und der Plugin-Zustand ziehen mit um.
|
||||
* Neue Installationen legen die Tabellen gleich unter den neuen Namen an.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (Schema::hasTable('documents') && ! Schema::hasTable('downloads')) {
|
||||
Schema::rename('document_folders', 'download_folders');
|
||||
Schema::rename('documents', 'downloads');
|
||||
Schema::rename('document_versions', 'download_versions');
|
||||
Schema::table('download_versions', fn (Blueprint $table) => $table->renameColumn('document_id', 'download_id'));
|
||||
}
|
||||
|
||||
if (Schema::hasTable('document_favorites') && ! Schema::hasTable('download_favorites')) {
|
||||
Schema::rename('document_favorites', 'download_favorites');
|
||||
Schema::table('download_favorites', fn (Blueprint $table) => $table->renameColumn('document_id', 'download_id'));
|
||||
}
|
||||
|
||||
if (Schema::hasTable('downloads') && Schema::hasColumn('downloads', 'downloads')) {
|
||||
Schema::table('downloads', fn (Blueprint $table) => $table->renameColumn('downloads', 'download_count'));
|
||||
}
|
||||
|
||||
// Rechte und Sichtbarkeiten
|
||||
DB::table('grants')->where('ability', 'documents.manage')->update(['ability' => 'downloads.manage']);
|
||||
DB::table('grants')->where('ability', 'documents.edit')->update(['ability' => 'downloads.edit']);
|
||||
DB::table('grants')->where('resource_type', 'document_folder')->update(['resource_type' => 'download_folder']);
|
||||
DB::table('audiences')->where('resource_type', 'document_folder')->update(['resource_type' => 'download_folder']);
|
||||
|
||||
// Einstellungen: Menü-Einträge und Anordnung der Startseite
|
||||
$this->updateSetting('navigation.menu', function (array $menu) {
|
||||
$rename = function (array $item) use (&$rename) {
|
||||
if (($item['type'] ?? null) === 'module' && ($item['module'] ?? null) === 'documents') {
|
||||
$item['module'] = 'downloads';
|
||||
}
|
||||
if (isset($item['children']) && is_array($item['children'])) {
|
||||
$item['children'] = array_map($rename, $item['children']);
|
||||
}
|
||||
|
||||
return $item;
|
||||
};
|
||||
|
||||
return array_map($rename, $menu);
|
||||
});
|
||||
$this->updateSetting('dashboard.layout', function (array $layout) {
|
||||
if (isset($layout['documents.favorites'])) {
|
||||
$layout['downloads.favorites'] = $layout['documents.favorites'];
|
||||
unset($layout['documents.favorites']);
|
||||
}
|
||||
|
||||
return $layout;
|
||||
});
|
||||
|
||||
// Pagebuilder-Blöcke in Seiten und ihren Fassungen
|
||||
foreach (['pages' => ['content', 'draft', 'scheduled_content'], 'page_revisions' => ['content']] as $table => $columns) {
|
||||
if (! Schema::hasTable($table)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($columns as $column) {
|
||||
DB::table($table)->where($column, 'like', '%documents.folder%')->orderBy('id')->each(function ($row) use ($table, $column) {
|
||||
DB::table($table)->where('id', $row->id)->update([
|
||||
$column => str_replace('"documents.folder"', '"downloads.folder"', $row->{$column}),
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Plugin-Zustand (z. B. „deaktiviert“) übernehmen
|
||||
$state = app(PluginState::class);
|
||||
$old = $state->all()['documents'] ?? null;
|
||||
|
||||
if (is_array($old)) {
|
||||
$state->setEnabled('downloads', (bool) ($old['enabled'] ?? true), $old['disabled_reason'] ?? null);
|
||||
$state->forget('documents');
|
||||
}
|
||||
|
||||
app(Settings::class)->flush();
|
||||
Permissions::flush();
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Umbenennung wird nicht zurückgenommen.
|
||||
}
|
||||
|
||||
private function updateSetting(string $key, callable $change): void
|
||||
{
|
||||
$row = DB::table('settings')->where('key', $key)->first();
|
||||
$value = $row ? json_decode((string) $row->value, true) : null;
|
||||
|
||||
if (is_array($value)) {
|
||||
DB::table('settings')->where('key', $key)->update(['value' => json_encode($change($value), JSON_UNESCAPED_UNICODE)]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// Zweimal ausführen schadet nicht (Umbenennung älterer Installationen, siehe 2026_09_29_000002).
|
||||
if (! Schema::hasTable('download_favorites')) {
|
||||
Schema::create('download_favorites', function (Blueprint $table) {
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('download_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
|
||||
$table->primary(['user_id', 'download_id']);
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('downloads', 'download_count')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('downloads', function (Blueprint $table) {
|
||||
$table->unsignedInteger('download_count')->default(0)->after('updated_by');
|
||||
$table->index('download_count');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('downloads', function (Blueprint $table) {
|
||||
$table->dropIndex(['download_count']);
|
||||
$table->dropColumn('download_count');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('download_favorites');
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue