Löschen von Themen und Fächern eingebaut
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"displayName": "Englisch",
|
||||
"description": "He she it das s muss mit!",
|
||||
"color": "#17B750",
|
||||
"color": "#17b750",
|
||||
"icon": "fa-language"
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"displayName": "Physik",
|
||||
"description": "Noch ein Fach",
|
||||
"color": "#363cfc",
|
||||
"icon": "fa-square-root-alt"
|
||||
}
|
||||
@@ -50,6 +50,10 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$errors["icon"] = "Bitte geben Sie ein Icon an.";
|
||||
}
|
||||
|
||||
if(!isset($_POST['submit']) || !($_POST['submit'] == "Speichern" || $_POST['submit'] == "Fach löschen")) {
|
||||
$errors["submit"] = "Ungültig abgeschickt!";
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$newSubject = false;
|
||||
if(isset($allSubjects[$_POST['id']])) {
|
||||
@@ -65,11 +69,15 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if(!$newSubject) {
|
||||
$errors["error"] = "Fehler beim Speichern des Faches.";
|
||||
} else {
|
||||
$newSubject->save();
|
||||
header("Location: " . "subject.php?subject=" . $newSubject->getId());
|
||||
if($_POST['submit'] == "Fach löschen") {
|
||||
$newSubject->delete();
|
||||
header("Location: " . "index.php");
|
||||
} else {
|
||||
$newSubject->save();
|
||||
header("Location: " . "subject.php?subject=" . $newSubject->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -184,16 +192,13 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-8 flex justify-end gap-3">
|
||||
<button type="button" onclick="closeModal()"
|
||||
class="px-6 py-3 text-gray-600 hover:text-gray-800 text-lg">
|
||||
Abbrechen
|
||||
</button>
|
||||
<button type="submit"
|
||||
class="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-lg">
|
||||
Speichern
|
||||
</button>
|
||||
<div class="flow-root mt-8 gap-4">
|
||||
<input type="submit" value="Fach löschen" name="submit"
|
||||
class="float-left px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-gray-200">
|
||||
<input type="submit" value="Speichern" name="submit"
|
||||
class="float-right px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
|
||||
<input type="button" value="Abbrechen" onclick="history.back()"
|
||||
class="float-right mx-2 px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -64,34 +64,47 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$errors["article"] = "Bitte geben Sie einen Erklärtext an.";
|
||||
}
|
||||
|
||||
if(!isset($_POST['submit']) || !($_POST['submit'] == "Speichern" || $_POST['submit'] == "Thema löschen")) {
|
||||
$errors["submit"] = "Ungültig abgeschickt!";
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$newTopic = false;
|
||||
|
||||
$relatedTopics = array();
|
||||
foreach (explode(",", $_POST['relatedTopics']) as $relatedTopic) {
|
||||
$relatedTopic = trim($relatedTopic);
|
||||
if($relatedTopic == "") {
|
||||
continue;
|
||||
}
|
||||
$relatedTopics[] = $relatedTopic;
|
||||
}
|
||||
|
||||
if(isset($allSubjects[$_POST['subjectId']]->getTopics()[$_POST['id']])) {
|
||||
$newTopic = $allSubjects[$_POST['subjectId']]->getTopics()[$_POST['id']];
|
||||
|
||||
$newTopic->setDisplayName($_POST['displayName']);
|
||||
$newTopic->setSubjectId($_POST['subjectId']);
|
||||
$newTopic->setDescription($_POST['description']);
|
||||
$newTopic->setIcon($_POST['icon']);
|
||||
|
||||
$relatedTopics = array();
|
||||
foreach (explode(",", $_POST['relatedTopics']) as $relatedTopic) {
|
||||
$relatedTopic = trim($relatedTopic);
|
||||
if($relatedTopic == "") {
|
||||
continue;
|
||||
}
|
||||
$relatedTopics[] = $relatedTopic;
|
||||
}
|
||||
$newTopic->setRelatedTopics($relatedTopics);
|
||||
$newTopic->setArticle($_POST['article']);
|
||||
} else {
|
||||
$newTopic = TopicData::createNew($_POST['id'], $_POST['subjectId'], $_POST['displayName'], $_POST['icon'], $_POST['description'], $_POST['relatedTopics'], $_POST['article']);
|
||||
$newTopic = TopicData::createNew($_POST['id'], $_POST['subjectId'], $_POST['displayName'], $_POST['icon'], $_POST['description'], $relatedTopics, $_POST['article']);
|
||||
}
|
||||
|
||||
if(!$newTopic) {
|
||||
$errors["error"] = "Fehler beim Speichern des Themas.";
|
||||
} else {
|
||||
$newTopic->save();
|
||||
header("Location: " . "topic.php?subject=" . $newTopic->getSubjectId() . "&topic=" . $newTopic->getId());
|
||||
if($_POST['submit'] == "Thema löschen") {
|
||||
$newTopic->delete();
|
||||
header("Location: " . "subject.php?subject=" . $_POST['subjectId']);
|
||||
} else {
|
||||
$newTopic->save();
|
||||
header("Location: " . "topic.php?subject=" . $newTopic->getSubjectId() . "&topic=" . $newTopic->getId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,15 +223,13 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
<div id="contentPreview" class="content-text prose prose-lg max-w-none bg-white p-6 rounded-lg shadow-sm"></div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-4">
|
||||
<button type="button" onclick="closeModal()"
|
||||
class="px-4 py-2 text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200">
|
||||
Abbrechen
|
||||
</button>
|
||||
<button type="submit"
|
||||
class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
|
||||
Speichern
|
||||
</button>
|
||||
<div class="flow-root gap-4">
|
||||
<input type="submit" value="Thema löschen" name="submit"
|
||||
class="float-left px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-gray-200">
|
||||
<input type="submit" value="Speichern" name="submit"
|
||||
class="float-right px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
|
||||
<input type="button" value="Abbrechen" onclick="history.back()"
|
||||
class="float-right mx-2 px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200">
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="article" id="article-upload-field">
|
||||
|
||||
Reference in New Issue
Block a user