added create and eedit note functionality (flawed)

This commit is contained in:
Felix Ivo
2025-06-27 09:56:46 +02:00
parent 1e9705aa13
commit 24c8f38c4d
4 changed files with 50 additions and 12 deletions

View File

@@ -2,13 +2,11 @@
namespace ppa\Controller;
/**
* Description of Welcome
*
* @author reich
*/
class WelcomeController
{
private $notesModel;
private $view;
public function setView(\ppa\Library\View $view)
{
$this->view = $view;
@@ -16,5 +14,36 @@ class WelcomeController
function showWelcome()
{
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');
}
}
}