refactoring
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
function user_view($user_id)
|
||||
{
|
||||
$user = exec_stmt('SELECT user_id, username, email, role_id, created_at, last_active, is_active, profile_picture FROM user WHERE user_id = ?', 'i', $user_id)->fetch_assoc();
|
||||
if ($user == null)
|
||||
header('Location: articles.php');
|
||||
|
||||
$view = '
|
||||
<div class="user_view">
|
||||
<div class="row">
|
||||
<h1>' . $user['username'] . '</h1>
|
||||
<div class="card_pic_box">
|
||||
<img src="' . $_ENV['PROFILE_IMAGES_PQ_PATH'] . $user['profile_picture'] . '" class="profile_picture" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="line"></div>
|
||||
';
|
||||
|
||||
// TODO: Allow user to update profile picture.
|
||||
// <button id="update_profile_picture_form_button" class="modal_button underline">Update Profile Picture</button>
|
||||
// <div id="update_profile_picture_form" class="modal_form">' . update_profile_picture_form() . '</div>
|
||||
if ((isset($_COOKIE['user_id']) && $_COOKIE['user_id'] == $user_id) || (isset($_COOKIE['role_id']) && $_COOKIE['role_id'] <= 2)) {
|
||||
$view .= '
|
||||
<h3>User Actions</h3>
|
||||
<div class="user_actions">
|
||||
<button id="reset_pw_form_button" class="modal_button underline">Reset Password</button>
|
||||
<button id="update_email_form_button" class="modal_button underline">Update Email</button>
|
||||
<button id="update_username_form_button" class="modal_button underline">Update Username</button>
|
||||
<button id="request_role_form_button" class="modal_button underline">Request Role</button>
|
||||
<button id="delete_account_form_button" class="modal_button underline">Delete Account</button>
|
||||
</div>
|
||||
|
||||
<div id="user_actions_modal" class="modal">
|
||||
<div id="modal_content"></div>
|
||||
</div>
|
||||
|
||||
<div style="display: none;">
|
||||
<div id="reset_pw_form" class="modal_form">' . reset_pw_form() . '</div>
|
||||
<div id="update_email_form" class="modal_form">' . update_email_form() . '</div>
|
||||
<div id="update_username_form" class="modal_form">' . update_username_form() . '</div>
|
||||
<div id="request_role_change_form" class="modal_form">' . request_role_change_form() . '</div>
|
||||
<div id="delete_account_form" class="modal_form">' . delete_account_form() . '</div>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
} else {
|
||||
$ids = articles_ids_by_author($_GET['user_id']);
|
||||
$view .= '
|
||||
<div class="article_cards">
|
||||
';
|
||||
|
||||
foreach ($ids as $id)
|
||||
$view .= article_card($id);
|
||||
|
||||
$view .= '</div>';
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
Reference in New Issue
Block a user