added admin page
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user