Ändern der ID von bereits existierenden Fächern eingebaut

This commit is contained in:
Matthias Grief
2025-01-07 11:34:06 +01:00
parent e01ae0161c
commit d4966ed313
2 changed files with 11 additions and 2 deletions

View File

@@ -243,6 +243,11 @@ class SubjectData
public function setId(string $id): void public function setId(string $id): void
{ {
rename(
Config::getSubjectDirectory($this->getId()),
Config::getSubjectDirectory($id)
);
$this->id = $id; $this->id = $id;
} }

View File

@@ -63,8 +63,10 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($errors)) { if (empty($errors)) {
$newSubject = false; $newSubject = false;
if (isset($allSubjects[$_POST['id']])) { if (isset($allSubjects[$_POST['oldSubjectId']])) {
$newSubject = $allSubjects[$_POST['id']]; $newSubject = $allSubjects[$_POST['oldSubjectId']];
$newSubject->setId($_POST['id']);
$newSubject->setDisplayName($_POST['displayName']); $newSubject->setDisplayName($_POST['displayName']);
$newSubject->setDescription($_POST['description']); $newSubject->setDescription($_POST['description']);
$newSubject->setColor($_POST['color']); $newSubject->setColor($_POST['color']);
@@ -129,6 +131,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
class="w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-lg enabled:hover:border-gray-400" class="w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-lg enabled:hover:border-gray-400"
placeholder="z.B. mathe" placeholder="z.B. mathe"
value="<?php echo $defaultValues['id'] ?>"> value="<?php echo $defaultValues['id'] ?>">
<input type="hidden" name="oldSubjectId" value="<?php echo $defaultValues['id']; ?>">
</div> </div>
<div> <div>