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