implemented following users to receive (opt-in) email notifications when they publish an article.
This commit is contained in:
@@ -1,14 +1,50 @@
|
||||
<?php
|
||||
include_once 'components/article/card.php';
|
||||
|
||||
function user_view($user_id)
|
||||
{
|
||||
if ($_SESSION['user_id'] != $user_id)
|
||||
$following = exec_stmt('SELECT follower_user_id, following_user_id FROM follows WHERE follower_user_id = ? AND following_user_id = ?', 'ii', $_SESSION['user_id'], $user_id)->fetch_assoc();
|
||||
$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');
|
||||
header('Location: articles.php?view=sort&sort=newest');
|
||||
|
||||
$view = '
|
||||
<div class="user_view">
|
||||
<div class="row">
|
||||
<h1>' . $user['username'] . '</h1>
|
||||
<div class="row">
|
||||
<h1>' . $user['username'] . '</h1>
|
||||
';
|
||||
|
||||
if ($_SESSION['user_id'] != $user_id && !$following) {
|
||||
$view .= '
|
||||
<div class="dropdown">
|
||||
<span>Follow</span>
|
||||
<div class="dropdown_content">
|
||||
<form method="post">
|
||||
<input type="hidden" name="form_id" value="follow">
|
||||
<input type="hidden" name="author_id" value="' . $user_id . '">
|
||||
<button name="follow" value="no_notify" class="button"><i class="nf nf-md-bell_cancel"></i></button>
|
||||
<button name="follow" value="email_notify" class="button"><i class="nf nf-cod-mail"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
} else if ($following) {
|
||||
$view .= '
|
||||
<div class="margin_right">
|
||||
<form method="post">
|
||||
<input type="hidden" name="form_id" value="unfollow">
|
||||
<input type="hidden" name="author_id" value="' . $user_id . '">
|
||||
<input type="submit" value="Unfollow">
|
||||
</form>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
$view .= '
|
||||
</div>
|
||||
<div class="card_pic_box">
|
||||
<img src="' . $_ENV['PROFILE_IMAGES_PQ_PATH'] . $user['profile_picture'] . '" class="profile_picture" />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user