EIANotesApp/Controller/NotesController.php
2025-06-16 15:11:33 +02:00

39 lines
889 B
PHP

<?php
namespace ppa\Controller;
use ppa\Model\NotesModel;
use ppa\Library\View;
class NotesController
{
private $notesModel;
protected $view;
public function __construct($view)
{
$this->notesModel = new NotesModel();
$this->view = $view;
}
public function showNotes()
{
$sortBy = $_GET['sort_by'] ?? 'updated_at';
$sortOrder = strtoupper($_GET['sort_order'] ?? 'DESC');
$isAdmin = $_SESSION['role'] === 'admin';
$userid = $_SESSION['user_id'];
$this->view->setVars([
"notes" => $this->notesModel->selectNotesForUser($userid, $isAdmin, $sortBy, $sortOrder)
]);
}
public function showNoteDetails()
{
$noteId = $_GET['id'];
$note = $this->notesModel->getNoteById($noteId);
$this->view->setVars([
"note" => $note
]);
}
}