Ändern von ID und Fach von existierenden Themen eingebaut

This commit is contained in:
Matthias Grief
2025-01-07 11:29:41 +01:00
parent c66ff41878
commit e01ae0161c
2 changed files with 17 additions and 2 deletions

View File

@@ -487,6 +487,11 @@ class TopicData
public function setId(string $id): void
{
rename(
Config::getTopicDirectory($this->getSubjectId(), $this->getId()),
Config::getTopicDirectory($this->getSubjectId(), $id)
);
$this->id = $id;
}
@@ -497,6 +502,11 @@ class TopicData
public function setSubjectId(string $subjectId): void
{
rename(
Config::getTopicDirectory($this->getSubjectId(), $this->getId()),
Config::getTopicDirectory($subjectId, $this->getId())
);
$this->subjectId = $subjectId;
}

View File

@@ -191,9 +191,10 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$article = preg_replace("/^[ \r\n\t]*<p><p>/", "<p>", $article);
$article = preg_replace("#</p></p>[ \r\n\t]*$#", "</p>", $article);
if (isset($allSubjects[$_POST['subjectId']]->getTopics()[$_POST['id']])) {
$newTopic = $allSubjects[$_POST['subjectId']]->getTopics()[$_POST['id']];
if (isset($allSubjects[$_POST['oldSubjectId']]->getTopics()[$_POST['oldTopicId']])) {
$newTopic = $allSubjects[$_POST['oldSubjectId']]->getTopics()[$_POST['oldTopicId']];
$newTopic->setId($_POST['id']);
$newTopic->setDisplayName($_POST['displayName']);
$newTopic->setSubjectId($_POST['subjectId']);
$newTopic->setDescription($_POST['description']);
@@ -289,6 +290,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"
required
value="<?php echo $defaultValues['id']; ?>">
<input type="hidden" name="oldTopicId" value="<?php echo $defaultValues['id']; ?>">
</div>
<div>
@@ -312,6 +315,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
<path d="M7 10l5 5 5-5H7z"/>
</svg>
</div>
<input type="hidden" name="oldSubjectId" value="<?php echo $defaultValues['subjectId']; ?>">
</div>
</div>