Merge branch 'main' of http://git.pb.bib.de/PBBFA23CIV/EIANotesApp
This commit is contained in:
@@ -52,7 +52,6 @@ class NotesController
|
||||
$_POST['content'],
|
||||
$_SESSION['user_id']
|
||||
);
|
||||
exit();
|
||||
|
||||
if ($note) {
|
||||
// Redirect to show notes page after successful creation
|
||||
@@ -89,8 +88,12 @@ class NotesController
|
||||
|
||||
public function deleteNote()
|
||||
{
|
||||
$noteId = $_GET['id'];
|
||||
$this->notesModel->deleteNote($noteId, $_SESSION['user_id']);
|
||||
header("Location: ?controller=Notes&page=showNotes");
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['note_id'])) {
|
||||
$noteId = $_POST['note_id'];
|
||||
$this->notesModel->deleteNote($noteId, $_SESSION['user_id']);
|
||||
}
|
||||
|
||||
header("Location: ?controller=Notes&page=showNotes&do=showNotes");
|
||||
exit();
|
||||
}
|
||||
}
|
@@ -17,33 +17,5 @@ class WelcomeController
|
||||
if ($this->notesModel === null) {
|
||||
$this->notesModel = new \ppa\Model\NotesModel();
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if ($_POST['action'] === 'create_note') {
|
||||
$this->notesModel->createNote(
|
||||
$_POST['title'],
|
||||
$_POST['content'],
|
||||
$_SESSION['user_id']
|
||||
);
|
||||
exit();
|
||||
}
|
||||
else if ($_POST['action'] === 'update_note') {
|
||||
$this->notesModel->editNote(
|
||||
$_POST['note_id'],
|
||||
$_POST['title'],
|
||||
$_POST['content'],
|
||||
$_SESSION['user_id']
|
||||
);
|
||||
exit();
|
||||
}
|
||||
else if ($_POST['action'] === 'delete_note') {
|
||||
$this->notesModel->deleteNote(
|
||||
$_POST['note_id'],
|
||||
$_SESSION['user_id']
|
||||
);
|
||||
exit();
|
||||
}
|
||||
header('Location: ?controller=Notes&page=showNotes&do=showNotes');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user