added admin page

This commit is contained in:
Felix Ivo
2025-07-07 14:42:34 +02:00
parent c5ebde8b20
commit 9bca8fd1d1
4 changed files with 167 additions and 1 deletions

View File

@@ -101,4 +101,39 @@ class NotesController
header("Location: ?controller=Notes&page=showNotes&do=showNotes");
exit();
}
public function fileManager()
{
# Redirect zum Login wenn kein User eingeloggt ist
if(!Isset($_SESSION['role']))
{
header("Location: ?controller=User&do=showUserLoginForm");
}
# Redirect zum Welcome wenn kein User kein Admin ist
if(!Isset($_SESSION['role']) || $_SESSION['role'] !== 'admin')
{
header("Location: ?controller=Welcome&do=showWelcome");
}
$sortBy = $_GET['sort_by'] ?? 'uploaded_at';
$sortOrder = strtoupper($_GET['sort_order'] ?? 'DESC');
$isAdmin = $_SESSION['role'] === 'admin';
$userid = $_SESSION['user_id'];
$files = $this->notesModel->selectFiles($userid, true);
$this->view->setVars([
"files" => $files
]);
}
public function deleteFile()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['file_id'])) {
$fileId = $_POST['file_id'];
$this->notesModel->deleteFile($fileId, $_SESSION['user_id']);
}
header("Location: ?controller=Notes&do=fileManager");
exit();
}
}