diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-04-24 09:40:20 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-04-24 09:40:20 -0600 |
commit | 7c3f2e348c015ea93563d866f89ec8cea9159ea0 (patch) | |
tree | b7b6b18cf9087f42300f621d15101628a8d214e4 /viewthread.php | |
parent | 6c9369ad85f2fb3dc61234b54db7e7079cdc0c4e (diff) |
Refactoring part 2
Starting to move some functionality such as the session and database connection into singleton classes to manage them. Functions for modifying posts and threads are being put in one place as well.
Diffstat (limited to 'viewthread.php')
-rw-r--r-- | viewthread.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/viewthread.php b/viewthread.php index ae08090..cc2d221 100644 --- a/viewthread.php +++ b/viewthread.php @@ -34,11 +34,10 @@ in <b><?= $current->category->name; ?></b> <?php include_once('includes/model/User.php'); -if (isset($_SESSION['signed_in'])) { - $user = new User(); - $user->get_by_id($_SESSION['user_id'], $dbc); +if (Session::get()->is_signed_in()) { + $user = Session::get()->get_current_user(); - if ($user->level > 0) { + if ($user->level == USER_LEVEL_MODERATOR) { echo ' <form action="moderate.php" method="post"> <p> @@ -75,6 +74,8 @@ foreach ($posts as $post) { </body> </html> <?php +include_once 'includes/functions_post.php'; + if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!isset($_SESSION['signed_in'])) { echo 'You must be <a href="signin.php">signed in</a> to reply to this thread.'; @@ -87,7 +88,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (empty($post_content) or !$post_content) { echo 'Thread subject cannot be empty'; } else { - insert_post($dbc, $post_content, $current->id, $user_id, $current->category->id); + create_post($post_content, $current->id, $current->category->id); } } ?> |