V5
This commit is contained in:
parent
27c6849991
commit
faaf46de25
@ -101,7 +101,7 @@ body {
|
||||
background-color: #161b22;
|
||||
padding: 40px 0;
|
||||
color: #8b949e;
|
||||
border-top: 1px solid #30363d;
|
||||
border-top: 1px solid #3036d;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
@ -174,6 +174,10 @@ h2 {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.discussion-card .card-text {
|
||||
color: #c9d1d9 !important;
|
||||
}
|
||||
|
||||
.pagination .page-item .page-link {
|
||||
background-color: #161b22;
|
||||
border-color: #30363d;
|
||||
@ -222,14 +226,243 @@ h2 {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
|
||||
.profile-container {
|
||||
background-color: #161b22;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 1rem;
|
||||
padding: 3rem;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 15px;
|
||||
padding: 2rem;
|
||||
margin-top: 2rem;
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.event-card {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 15px;
|
||||
margin-bottom: 1.5rem;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||
}
|
||||
|
||||
.event-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.event-card a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.event-card-header {
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
padding: 1rem 1.5rem;
|
||||
}
|
||||
|
||||
.event-card-header h5 {
|
||||
margin-bottom: 0;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.event-card-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.event-card-footer {
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
padding: 1rem 1.5rem;
|
||||
font-size: 0.9rem;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.proposal-card {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 15px;
|
||||
margin-bottom: 1.5rem;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||
}
|
||||
|
||||
.proposal-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.proposal-card a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.proposal-card-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.proposal-card-footer {
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
padding: 1rem 1.5rem;
|
||||
font-size: 0.9rem;
|
||||
color: #ccc;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.event-details-container {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 15px;
|
||||
padding: 2.5rem;
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.event-details-header {
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
||||
padding-bottom: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.rsvp-section {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 15px;
|
||||
padding: 2rem;
|
||||
margin-top: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.rsvp-count {
|
||||
font-size: 3rem;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.rsvp-label {
|
||||
font-size: 1.2rem;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.proposal-details-container {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 15px;
|
||||
padding: 2.5rem;
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.proposal-details-header {
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
||||
padding-bottom: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.proposal-status {
|
||||
font-size: 1.2rem;
|
||||
font-weight: bold;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 8px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.proposal-status-pending {
|
||||
background-color: #ffc107;
|
||||
}
|
||||
|
||||
.proposal-status-approved {
|
||||
background-color: #28a745;
|
||||
}
|
||||
|
||||
.proposal-status-rejected {
|
||||
background-color: #dc3545;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 15px;
|
||||
margin-bottom: 1rem;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||
}
|
||||
|
||||
.message-item:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.message-item a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
padding: 1.5rem;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.message-item-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 15px;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
height: 60vh;
|
||||
overflow-y: auto;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.message-bubble {
|
||||
border-radius: 20px;
|
||||
padding: 0.8rem 1rem;
|
||||
max-width: 75%;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.message-sent {
|
||||
background-color: #0d6efd;
|
||||
color: white;
|
||||
align-self: flex-end;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.message-received {
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
color: white;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.chat-input-group {
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.chat-input-group .form-control {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.chat-input-group .form-control::placeholder {
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
|
||||
.profile-avatar {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
|
||||
@ -44,6 +44,7 @@ try {
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="communities.php">Communities</a></li>
|
||||
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
|
||||
@ -43,20 +43,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['message'])) {
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Conversation with <?php echo htmlspecialchars($with_user['username']); ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
<title>Conversation with <?php echo htmlspecialchars($with_user['username']); ?> - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</a>
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<i class="fas fa-cubes me-2"></i>Community Hub
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
@ -64,8 +68,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['message'])) {
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php">Proposals</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="messages.php">Messages</a></li>
|
||||
@ -75,36 +81,44 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['message'])) {
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4 flex-grow-1">
|
||||
<h3>Conversation with <?php echo htmlspecialchars($with_user['username']); ?></h3>
|
||||
<div class="card">
|
||||
<div class="card-body" style="height: 400px; overflow-y: scroll;">
|
||||
<main class="container mt-5 flex-grow-1 d-flex flex-column">
|
||||
<div class="text-center mb-4">
|
||||
<h1 class="display-5 text-white">Conversation with <?php echo htmlspecialchars($with_user['username']); ?></h1>
|
||||
</div>
|
||||
|
||||
<div class="chat-container flex-grow-1 d-flex flex-column">
|
||||
<div class="chat-messages flex-grow-1">
|
||||
<?php foreach ($messages as $msg): ?>
|
||||
<div class="d-flex <?php echo $msg['sender_id'] == $user_id ? 'justify-content-end' : ''; ?> mb-3">
|
||||
<div class="card <?php echo $msg['sender_id'] == $user_id ? 'bg-primary text-white' : 'bg-light'; ?>" style="max-width: 70%;">
|
||||
<div class="card-body">
|
||||
<p class="card-text"><?php echo htmlspecialchars($msg['message']); ?></p>
|
||||
<small class="text-muted d-block text-end"><?php echo date('M j, Y, g:i a', strtotime($msg['created_at'])); ?></small>
|
||||
</div>
|
||||
<div class="d-flex <?php echo $msg['sender_id'] == $user_id ? 'justify-content-end' : 'justify-content-start'; ?> mb-3">
|
||||
<div class="message-bubble <?php echo $msg['sender_id'] == $user_id ? 'message-sent' : 'message-received'; ?>">
|
||||
<p class="mb-0"><?php echo htmlspecialchars($msg['message']); ?></p>
|
||||
<small class="d-block text-end mt-1 opacity-75"><?php echo date('g:i a', strtotime($msg['created_at'])); ?></small>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="chat-input-group">
|
||||
<form method="POST">
|
||||
<div class="input-group">
|
||||
<input type="text" name="message" class="form-control" placeholder="Type your message...">
|
||||
<button type="submit" class="btn btn-primary">Send</button>
|
||||
<input type="text" name="message" class="form-control" placeholder="Type your message..." autocomplete="off">
|
||||
<button type="submit" class="btn btn-primary"><i class="fas fa-paper-plane"></i></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
// Scroll to the bottom of the chat on page load
|
||||
const chatMessages = document.querySelector('.chat-messages');
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -8,39 +8,83 @@ if (!isset($_SESSION['user_id'])) {
|
||||
}
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$community_id = $_GET['community_id'] ?? null;
|
||||
|
||||
if (!$community_id) {
|
||||
echo "Community ID is required.";
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('SELECT * FROM communities WHERE id = ?');
|
||||
$stmt->execute([$community_id]);
|
||||
$community = $stmt->fetch();
|
||||
|
||||
if (!$community) {
|
||||
echo "Community not found.";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fetch user role
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$user_id]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['title']) && !empty($_POST['description'])) {
|
||||
$title = $_POST['title'];
|
||||
$description = $_POST['description'];
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (!empty($_POST['title']) && !empty($_POST['description'])) {
|
||||
$title = $_POST['title'];
|
||||
$description = $_POST['description'];
|
||||
$end_time = !empty($_POST['end_time']) ? date('Y-m-d H:i:s', strtotime($_POST['end_time'])) : date('Y-m-d H:i:s', strtotime('+7 days'));
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO proposals (user_id, title, description) VALUES (?, ?, ?)");
|
||||
$stmt->execute([$user_id, $title, $description]);
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT INTO proposals (user_id, community_id, title, description, end_time) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$user_id, $community_id, $title, $description, $end_time]);
|
||||
|
||||
header("Location: proposals.php");
|
||||
exit;
|
||||
// Send email notification
|
||||
require_once __DIR__ . '/mail/MailService.php';
|
||||
$user_stmt = $pdo->prepare('SELECT email, name FROM users WHERE id = ?');
|
||||
$user_stmt->execute([$user_id]);
|
||||
$user = $user_stmt->fetch();
|
||||
|
||||
if ($user) {
|
||||
$to = $user['email'];
|
||||
$subject = "Proposal Created: " . $title;
|
||||
$html_content = "<h1>Your new proposal has been created!</h1><p><b>Title:</b> {$title}</p><p><b>Community:</b> {$community['name']}</p>";
|
||||
$text_content = "Your new proposal '{$title}' has been created in the community '{$community['name']}'.";
|
||||
MailService::sendMail($to, $subject, $html_content, $text_content);
|
||||
}
|
||||
|
||||
header("Location: proposals.php?community_id=$community_id");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo "Title and description are required.";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>New Proposal</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
<title>New Proposal - <?php echo htmlspecialchars($community['name']); ?> - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</a>
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<i class="fas fa-cubes me-2"></i>Community Hub
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
@ -48,8 +92,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['title']) && !empty($
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="discussions.php?community_id=<?php echo $community_id; ?>">Discussions</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php?community_id=<?php echo $community_id; ?>">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php?community_id=<?php echo $community_id; ?>">Proposals</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
@ -59,25 +106,39 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['title']) && !empty($
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4 flex-grow-1">
|
||||
<h2>Create New Proposal</h2>
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">Title</label>
|
||||
<input type="text" class="form-control" id="title" name="title" required>
|
||||
<main class="container mt-5 flex-grow-1">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8">
|
||||
<div class="form-container">
|
||||
<h2 class="text-white text-center mb-4">Create a New Proposal in <?php echo htmlspecialchars($community['name']); ?></h2>
|
||||
<form method="POST" action="create_proposal.php?community_id=<?php echo $community_id; ?>">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label text-white-50">Title</label>
|
||||
<input type="text" class="form-control" id="title" name="title" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="description" class="form-label text-white-50">Description</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="8" required></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="end_time" class="form-label text-white-50">End Time</label>
|
||||
<input type="datetime-local" class="form-control" id="end_time" name="end_time">
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary btn-lg">Submit Proposal</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="5" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit Proposal</button>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-.dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@ -80,8 +80,8 @@ $replies = $stmt->fetchAll();
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
@ -91,12 +91,19 @@ $replies = $stmt->fetchAll();
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php">Proposals</a></li>
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
<?php else: ?>
|
||||
<li class="nav-item"><a class="nav-link" href="login.php">Login</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="signup.php">Sign Up</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -104,13 +111,13 @@ $replies = $stmt->fetchAll();
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<div class="card card-neon mb-4">
|
||||
<div class="card bg-dark text-white mb-4">
|
||||
<div class="card-header">
|
||||
<h1 class="mb-0"><?php echo htmlspecialchars($discussion['title']); ?></h1>
|
||||
<small>in <a href="discussions.php?community_id=<?php echo $discussion['community_id']; ?>"><?php echo htmlspecialchars($discussion['community_name']); ?></a> by <?php echo htmlspecialchars($discussion['user_name']); ?> on <?php echo date('M j, Y, g:i a', strtotime($discussion['created_at'])); ?></small>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><?php echo nl2br(htmlspecialchars($discussion['content'])); ?></p>
|
||||
<p class="card-text"><?php echo nl2br(htmlspecialchars($discussion['content'])); ?></p>
|
||||
<?php if ($discussion['user_id'] == $user_id || $user_role == 'leader'): ?>
|
||||
<div class="mt-3">
|
||||
<a href="edit_discussion.php?id=<?php echo $discussion['id']; ?>" class="btn btn-secondary btn-sm">Edit</a>
|
||||
@ -120,17 +127,17 @@ $replies = $stmt->fetchAll();
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Replies</h2>
|
||||
<h2 class="text-white">Replies</h2>
|
||||
<div class="mb-4">
|
||||
<?php if (empty($replies)): ?>
|
||||
<div class="text-center p-4" style="background-color: #161b22; border-radius: 0.5rem;">
|
||||
<?php if (empty($replies)):
|
||||
<div class="text-center p-4 bg-dark text-white" style="border-radius: 0.5rem;">
|
||||
<p class="mb-0">No replies yet. Be the first to reply!</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($replies as $reply): ?>
|
||||
<div class="card card-neon mb-3">
|
||||
<?php foreach ($replies as $reply):
|
||||
<div class="card bg-dark text-white mb-3">
|
||||
<div class="card-body">
|
||||
<p class="mb-1"><?php echo nl2br(htmlspecialchars($reply['content'])); ?></p>
|
||||
<p class="card-text"><?php echo nl2br(htmlspecialchars($reply['content'])); ?></p>
|
||||
<small>by <?php echo htmlspecialchars($reply['user_name']); ?> on <?php echo date('M j, Y, g:i a', strtotime($reply['created_at'])); ?></small>
|
||||
<?php if ($reply['user_id'] == $user_id || $user_role == 'leader'): ?>
|
||||
<div class="mt-2">
|
||||
@ -144,12 +151,12 @@ $replies = $stmt->fetchAll();
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="card card-neon">
|
||||
<div class="card bg-dark text-white">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Post a Reply</h2>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<?php if (!empty($errors):
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<?php foreach ($errors as $error):
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
@ -157,17 +164,19 @@ $replies = $stmt->fetchAll();
|
||||
<form action="discussion.php?id=<?php echo $discussion_id; ?>" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label">Your Reply</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="3" required><?php echo htmlspecialchars($content); ?></textarea>
|
||||
<textarea class="form-control bg-dark text-white" id="content" name="content" rows="3" required><?php echo htmlspecialchars($content); ?></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-gradient">Post Reply</button>
|
||||
<button type="submit" class="btn btn-primary">Post Reply</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
@ -89,11 +89,16 @@ $total_pages = ceil($total_discussions / $limit);
|
||||
// Fetch discussions for the current page
|
||||
$sql = 'SELECT d.*, u.name as user_name FROM discussions d JOIN users u ON d.user_id = u.id ' . $where_clause . ' ORDER BY d.created_at DESC LIMIT ? OFFSET ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$params[] = $limit;
|
||||
$params[] = $offset;
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
$stmt->bindValue($key + 1, $value, is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR);
|
||||
$stmt->bindParam(1, $community_id, PDO::PARAM_INT);
|
||||
if (!empty($search)) {
|
||||
$search_param = '%' . $search . '%';
|
||||
$stmt->bindParam(2, $search_param, PDO::PARAM_STR);
|
||||
$stmt->bindParam(3, $search_param, PDO::PARAM_STR);
|
||||
$stmt->bindParam(4, $limit, PDO::PARAM_INT);
|
||||
$stmt->bindParam(5, $offset, PDO::PARAM_INT);
|
||||
} else {
|
||||
$stmt->bindParam(2, $limit, PDO::PARAM_INT);
|
||||
$stmt->bindParam(3, $offset, PDO::PARAM_INT);
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
@ -121,6 +126,9 @@ $discussions = $stmt->fetchAll();
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="discussions.php?community_id=<?php echo $community_id; ?>">Discussions</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php?community_id=<?php echo $community_id; ?>">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php?community_id=<?php echo $community_id; ?>">Proposals</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
@ -180,9 +188,10 @@ $discussions = $stmt->fetchAll();
|
||||
<h5 class="mb-0">
|
||||
<a href="discussion.php?id=<?php echo $discussion['id']; ?>"><?php echo htmlspecialchars($discussion['title']); ?></a>
|
||||
</h5>
|
||||
<small class="text-muted"><?php echo date('M j, Y, g:i a', strtotime($discussion['created_at'])); ?></small>
|
||||
<small><?php echo date('M j, Y, g:i a', strtotime($discussion['created_at'])); ?></small>
|
||||
</div>
|
||||
<p class="mb-1 text-muted">Started by: <?php echo htmlspecialchars($discussion['user_name']); ?></p>
|
||||
<p class="mb-1">Started by: <?php echo htmlspecialchars($discussion['user_name']); ?></p>
|
||||
<p class="card-text"><?php echo htmlspecialchars($discussion['content']); ?></p>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@ -76,6 +76,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@ -83,22 +84,28 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Edit Discussion - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</a>
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<i class="fas fa-cubes me-2"></i>Community Hub
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php?community_id=<?php echo $discussion['community_id']; ?>">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php?community_id=<?php echo $discussion['community_id']; ?>">Proposals</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="discussions.php?community_id=<?php echo $discussion['community_id']; ">Discussions</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
@ -110,38 +117,45 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<h1 class="text-center mb-4">Edit Discussion</h1>
|
||||
<div class="card card-neon">
|
||||
<div class="card-body">
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="edit_discussion.php?id=<?php echo $discussion_id; ?>" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">Title</label>
|
||||
<input type="text" class="form-control" id="title" name="title" value="<?php echo htmlspecialchars($title); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label">Content</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="5" required><?php echo htmlspecialchars($content); ?></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-gradient">Save Changes</button>
|
||||
<a href="discussion.php?id=<?php echo $discussion_id; ?>" class="btn btn-secondary">Cancel</a>
|
||||
</form>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8">
|
||||
<div class="form-container">
|
||||
<h1 class="text-white text-center mb-4">Edit Discussion</h1>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="edit_discussion.php?id=<?php echo $discussion_id; ?>" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label text-white-50">Title</label>
|
||||
<input type="text" class="form-control" id="title" name="title" value="<?php echo htmlspecialchars($title); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label text-white-50">Content</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="8" required><?php echo htmlspecialchars($content); ?></textarea>
|
||||
</div>
|
||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||
<a href="discussion.php?id=<?php echo $discussion_id; ?>" class="btn btn-secondary me-md-2">Cancel</a>
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@ -32,6 +32,11 @@ $stmt = $pdo->prepare('SELECT * FROM discussion_replies WHERE id = ?');
|
||||
$stmt->execute([$reply_id]);
|
||||
$reply = $stmt->fetch();
|
||||
|
||||
// Fetch discussion to get community_id
|
||||
$stmt = $pdo->prepare('SELECT community_id FROM discussions WHERE id = ?');
|
||||
$stmt->execute([$reply['discussion_id']]);
|
||||
$discussion = $stmt->fetch();
|
||||
|
||||
if (!$reply) {
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
@ -71,6 +76,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@ -78,13 +84,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Edit Reply - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</a>
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<i class="fas fa-cubes me-2"></i>Community Hub
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
@ -92,9 +101,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php?community_id=<?php echo $discussion['community_id']; ?>">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php?community_id=<?php echo $discussion['community_id']; ?>">Proposals</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="discussions.php?community_id=<?php echo $discussion['community_id']; ">Discussions</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
@ -106,31 +117,37 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<h1 class="text-center mb-4">Edit Reply</h1>
|
||||
<div class="card card-neon">
|
||||
<div class="card-body">
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="edit_reply.php?id=<?php echo $reply_id; ?>" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label">Content</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="5" required><?php echo htmlspecialchars($content); ?></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-gradient">Save Changes</button>
|
||||
<a href="discussion.php?id=<?php echo $reply['discussion_id']; ?>" class="btn btn-secondary">Cancel</a>
|
||||
</form>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8">
|
||||
<div class="form-container">
|
||||
<h1 class="text-white text-center mb-4">Edit Reply</h1>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="edit_reply.php?id=<?php echo $reply_id; ?>" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label text-white-50">Content</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="8" required><?php echo htmlspecialchars($content); ?></textarea>
|
||||
</div>
|
||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||
<a href="discussion.php?id=<?php echo $reply['discussion_id']; ?>" class="btn btn-secondary me-md-2">Cancel</a>
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
82
event.php
82
event.php
@ -76,6 +76,7 @@ $stmt->execute([$user_id, $event_id]);
|
||||
$user_rsvp = $stmt->fetchColumn();
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@ -83,13 +84,16 @@ $user_rsvp = $stmt->fetchColumn();
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo htmlspecialchars($event['title']); ?> - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</a>
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<i class="fas fa-cubes me-2"></i>Community Hub
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
@ -97,8 +101,10 @@ $user_rsvp = $stmt->fetchColumn();
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php?community_id=<?php echo $event['community_id']; ?>">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php?community_id=<?php echo $event['community_id']; ?>">Proposals</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
@ -110,41 +116,51 @@ $user_rsvp = $stmt->fetchColumn();
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<div class="card card-neon mb-4">
|
||||
<div class="card-header">
|
||||
<h1 class="mb-0"><?php echo htmlspecialchars($event['title']); ?></h1>
|
||||
<small>in <a href="discussions.php?community_id=<?php echo $event['community_id']; ?>"><?php echo htmlspecialchars($event['community_name']); ?></a> by <?php echo htmlspecialchars($event['user_name']); ?> on <?php echo date('M j, Y, g:i a', strtotime($event['created_at'])); ?></small>
|
||||
<div class="event-details-container">
|
||||
<div class="event-details-header">
|
||||
<h1 class="display-4 text-white"><?php echo htmlspecialchars($event['title']); ?></h1>
|
||||
<p class="lead text-white-50">
|
||||
in <a href="discussions.php?community_id=<?php echo $event['community_id']; ?>" class="text-white-50"><?php echo htmlspecialchars($event['community_name']); ?></a> by <?php echo htmlspecialchars($event['user_name']); ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><?php echo nl2br(htmlspecialchars($event['description'])); ?></p>
|
||||
<p><strong>Starts:</strong> <?php echo date('M j, Y, g:i a', strtotime($event['start_time'])); ?></p>
|
||||
<p><strong>Ends:</strong> <?php echo date('M j, Y, g:i a', strtotime($event['end_time'])); ?></p>
|
||||
<p><strong>Location:</strong> <?php echo htmlspecialchars($event['location']); ?></p>
|
||||
<div class="event-details-body text-white">
|
||||
<p class="fs-5"><?php echo nl2br(htmlspecialchars($event['description'])); ?></p>
|
||||
<hr class="border-light">
|
||||
<div class="row mt-4 fs-5">
|
||||
<div class="col-md-4">
|
||||
<p><i class="fas fa-map-marker-alt me-2 text-primary"></i><strong>Location:</strong> <?php echo htmlspecialchars($event['location']); ?></p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<p><i class="far fa-clock me-2 text-primary"></i><strong>Starts:</strong> <?php echo date('M j, Y, g:i a', strtotime($event['start_time'])); ?></p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<p><i class="far fa-clock me-2 text-primary"></i><strong>Ends:</strong> <?php echo date('M j, Y, g:i a', strtotime($event['end_time'])); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>RSVPs</h2>
|
||||
<div class="d-flex justify-content-around mb-4">
|
||||
<div class="text-center">
|
||||
<h3>Attending</h3>
|
||||
<p class="display-4"><?php echo $attending; ?></p>
|
||||
<div class="rsvp-section">
|
||||
<h2 class="text-white mb-4">RSVPs</h2>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-4 text-center">
|
||||
<p class="rsvp-label">Attending</p>
|
||||
<p class="rsvp-count text-success"><?php echo $attending; ?></p>
|
||||
</div>
|
||||
<div class="col-md-4 text-center">
|
||||
<p class="rsvp-label">Not Attending</p>
|
||||
<p class="rsvp-count text-danger"><?php echo $not_attending; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<h3>Not Attending</h3>
|
||||
<p class="display-4"><?php echo $not_attending; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card card-neon">
|
||||
<div class="card-body text-center">
|
||||
<h2 class="card-title">RSVP</h2>
|
||||
<form action="event.php?id=<?php echo $event_id; ?>" method="POST" class="d-inline">
|
||||
<div class="mt-4">
|
||||
<h3 class="text-white mb-3">Will you be there?</h3>
|
||||
<form action="event.php?id=<?php echo $event_id; ?>" method="POST" class="d-inline">
|
||||
<input type="hidden" name="rsvp" value="attending">
|
||||
<button type="submit" class="btn btn-success btn-lg me-2 <?php echo ($user_rsvp === 'attending') ? 'active' : ''; ?>">Attending</button>
|
||||
<button type="submit" class="btn btn-success btn-lg me-2 <?php echo ($user_rsvp === 'attending') ? 'active' : ''; ?>"><i class="fas fa-check me-2"></i>Attending</button>
|
||||
</form>
|
||||
<form action="event.php?id=<?php echo $event_id; ?>" method="POST" class="d-inline">
|
||||
<input type="hidden" name="rsvp" value="not_attending">
|
||||
<button type="submit" class="btn btn-danger btn-lg <?php echo ($user_rsvp === 'not_attending') ? 'active' : ''; ?>">Not Attending</button>
|
||||
<button type="submit" class="btn btn-danger btn-lg <?php echo ($user_rsvp === 'not_attending') ? 'active' : ''; ?>"><i class="fas fa-times me-2"></i>Not Attending</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@ -152,8 +168,10 @@ $user_rsvp = $stmt->fetchColumn();
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
189
events.php
189
events.php
@ -1,4 +1,3 @@
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
@ -8,79 +7,77 @@ if (!isset($_SESSION['user_id'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fetch user role if logged in
|
||||
$user_role = null;
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
}
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$community_id = $_GET['community_id'] ?? null;
|
||||
|
||||
if (!isset($_GET['community_id'])) {
|
||||
header('Location: communities.php');
|
||||
if (!$community_id) {
|
||||
echo "Community ID is required.";
|
||||
exit;
|
||||
}
|
||||
|
||||
$community_id = $_GET['community_id'];
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch community details
|
||||
$stmt = $pdo->prepare('SELECT * FROM communities WHERE id = ?');
|
||||
$stmt->execute([$community_id]);
|
||||
$community = $stmt->fetch();
|
||||
|
||||
if (!$community) {
|
||||
header('Location: communities.php');
|
||||
echo "Community not found.";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Handle new event form submission
|
||||
$title = $description = $start_time = $end_time = $location = '';
|
||||
// Fetch user role
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$user_id]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
// Handle event creation
|
||||
$errors = [];
|
||||
$title = $description = $start_time = $end_time = $location = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$title = trim($_POST['title'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$start_time = trim($_POST['start_time'] ?? '');
|
||||
$end_time = trim($_POST['end_time'] ?? '');
|
||||
$start_time = $_POST['start_time'] ?? '';
|
||||
$end_time = $_POST['end_time'] ?? '';
|
||||
$location = trim($_POST['location'] ?? '');
|
||||
|
||||
if (empty($title)) {
|
||||
$errors[] = 'Title is required';
|
||||
$errors[] = 'Title is required.';
|
||||
}
|
||||
if (empty($description)) {
|
||||
$errors[] = 'Description is required';
|
||||
$errors[] = 'Description is required.';
|
||||
}
|
||||
if (empty($start_time)) {
|
||||
$errors[] = 'Start time is required';
|
||||
$errors[] = 'Start time is required.';
|
||||
}
|
||||
if (empty($end_time)) {
|
||||
$errors[] = 'End time is required';
|
||||
$errors[] = 'End time is required.';
|
||||
}
|
||||
if (empty($location)) {
|
||||
$errors[] = 'Location is required';
|
||||
$errors[] = 'Location is required.';
|
||||
}
|
||||
if (strtotime($start_time) >= strtotime($end_time)) {
|
||||
$errors[] = 'End time must be after start time.';
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
$stmt = $pdo->prepare('INSERT INTO events (community_id, user_id, title, description, start_time, end_time, location) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
||||
$stmt->execute([$community_id, $user_id, $title, $description, $start_time, $end_time, $location]);
|
||||
header('Location: events.php?community_id=' . $community_id);
|
||||
$stmt = $pdo->prepare('INSERT INTO events (community_id, user_id, title, description, start_time, end_time, location) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
||||
if ($stmt->execute([$community_id, $user_id, $title, $description, $start_time, $end_time, $location])) {
|
||||
header("Location: events.php?community_id=$community_id");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
$errors[] = 'Database error: ' . $e->getMessage();
|
||||
} else {
|
||||
$errors[] = 'Failed to create event. Please try again.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch events
|
||||
// Fetch events for the community
|
||||
$stmt = $pdo->prepare('SELECT e.*, u.name as user_name FROM events e JOIN users u ON e.user_id = u.id WHERE e.community_id = ? ORDER BY e.start_time DESC');
|
||||
$stmt->execute([$community_id]);
|
||||
$events = $stmt->fetchAll();
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@ -88,13 +85,16 @@ $events = $stmt->fetchAll();
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo htmlspecialchars($community['name']); ?> Events - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</a>
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<i class="fas fa-cubes me-2"></i>Community Hub
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
@ -102,8 +102,11 @@ $events = $stmt->fetchAll();
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="discussions.php?community_id=<?php echo $community_id; ?>">Discussions</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php?community_id=<?php echo $community_id; ?>">Proposals</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php?community_id=<?php echo $community_id; ?>">Events</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
@ -115,71 +118,87 @@ $events = $stmt->fetchAll();
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<h1 class="text-center mb-4">Events in <?php echo htmlspecialchars($community['name']); ?></h1>
|
||||
<div class="text-center mb-5">
|
||||
<h1 class="display-4 text-white">Events in <?php echo htmlspecialchars($community['name']); ?></h1>
|
||||
<p class="lead text-white-50">Stay up-to-date with the latest happenings.</p>
|
||||
</div>
|
||||
|
||||
<div class="card card-neon mb-4">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Create a New Event</h2>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
<div class="form-container mb-5">
|
||||
<h2 class="card-title text-white">Create a New Event</h2>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="events.php?community_id=<?php echo $community_id; ?>" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label text-white-50">Title</label>
|
||||
<input type="text" class="form-control" id="title" name="title" value="<?php echo htmlspecialchars($title); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="description" class="form-label text-white-50">Description</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="3" required><?php echo htmlspecialchars($description); ?></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="start_time" class="form-label text-white-50">Start Time</label>
|
||||
<input type="datetime-local" class="form-control" id="start_time" name="start_time" value="<?php echo htmlspecialchars($start_time); ?>" required>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="events.php?community_id=<?php echo $community_id; ?>" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">Title</label>
|
||||
<input type="text" class="form-control" id="title" name="title" value="<?php echo htmlspecialchars($title); ?>" required>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="end_time" class="form-label text-white-50">End Time</label>
|
||||
<input type="datetime-local" class="form-control" id="end_time" name="end_time" value="<?php echo htmlspecialchars($end_time); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="3" required><?php echo htmlspecialchars($description); ?></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="start_time" class="form-label">Start Time</label>
|
||||
<input type="datetime-local" class="form-control" id="start_time" name="start_time" value="<?php echo htmlspecialchars($start_time); ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="end_time" class="form-label">End Time</label>
|
||||
<input type="datetime-local" class="form-control" id="end_time" name="end_time" value="<?php echo htmlspecialchars($end_time); ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="location" class="form-label">Location</label>
|
||||
<input type="text" class="form-control" id="location" name="location" value="<?php echo htmlspecialchars($location); ?>" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-gradient">Create Event</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="location" class="form-label text-white-50">Location</label>
|
||||
<input type="text" class="form-control" id="location" name="location" value="<?php echo htmlspecialchars($location); ?>" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100">Create Event</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h2>Upcoming Events</h2>
|
||||
<div class="list-group">
|
||||
<h2 class="text-white mb-4">Upcoming Events</h2>
|
||||
<div class="row">
|
||||
<?php if (empty($events)): ?>
|
||||
<p>No events yet. Be the first to create one!</p>
|
||||
<div class="col">
|
||||
<div class="form-container text-center">
|
||||
<p class="lead text-white-50">No events yet. Be the first to create one!</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($events as $event): ?>
|
||||
<a href="event.php?id=<?php echo $event['id']; ?>" class="list-group-item list-group-item-action">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1"><?php echo htmlspecialchars($event['title']); ?></h5>
|
||||
<small><?php echo date('M j, Y, g:i a', strtotime($event['start_time'])); ?></small>
|
||||
<div class="col-lg-6">
|
||||
<div class="event-card">
|
||||
<a href="event.php?id=<?php echo $event['id']; ?>">
|
||||
<div class="event-card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0"><?php echo htmlspecialchars($event['title']); ?></h5>
|
||||
<span class="badge bg-primary"><?php echo date('M j', strtotime($event['start_time'])); ?></span>
|
||||
</div>
|
||||
<div class="event-card-body">
|
||||
<p class="mb-2"><i class="fas fa-map-marker-alt me-2 text-white-50"></i><?php echo htmlspecialchars($event['location']); ?></p>
|
||||
<p class="mb-0"><i class="far fa-clock me-2 text-white-50"></i><?php echo date('g:i a', strtotime($event['start_time'])); ?> - <?php echo date('g:i a', strtotime($event['end_time'])); ?></p>
|
||||
</div>
|
||||
<div class="event-card-footer">
|
||||
<small>Created by: <?php echo htmlspecialchars($event['user_name']); ?></small>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<p class="mb-1">Location: <?php echo htmlspecialchars($event['location']); ?></p>
|
||||
<p class="mb-1">Created by: <?php echo htmlspecialchars($event['user_name']); ?></p>
|
||||
</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@ -35,6 +35,7 @@ if (isset($_SESSION['user_id'])) {
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="index.php">Home</a></li>
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
|
||||
@ -11,61 +11,59 @@ $user_id = $_SESSION['user_id'];
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Check if user is a leader
|
||||
// Fetch user role
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$user_id]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
if ($user_role !== 'leader') {
|
||||
// Redirect non-leaders
|
||||
header('Location: communities.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Handle delete
|
||||
$errors = [];
|
||||
$name = '';
|
||||
$description = '';
|
||||
$edit_id = null;
|
||||
|
||||
// Handle community creation and updates
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$name = trim($_POST['name']);
|
||||
$description = trim($_POST['description']);
|
||||
$edit_id = $_POST['edit_id'] ?? null;
|
||||
|
||||
if (empty($name)) {
|
||||
$errors[] = 'Community name is required.';
|
||||
}
|
||||
if (empty($description)) {
|
||||
$errors[] = 'Description is required.';
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
if ($edit_id) {
|
||||
// Update existing community
|
||||
$stmt = $pdo->prepare('UPDATE communities SET name = ?, description = ? WHERE id = ? AND leader_id = ?');
|
||||
$stmt->execute([$name, $description, $edit_id, $user_id]);
|
||||
} else {
|
||||
// Create new community
|
||||
$stmt = $pdo->prepare('INSERT INTO communities (name, description, leader_id) VALUES (?, ?, ?)');
|
||||
$stmt->execute([$name, $description, $user_id]);
|
||||
}
|
||||
header('Location: manage_communities.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle community deletion
|
||||
if (isset($_GET['delete'])) {
|
||||
$community_id_to_delete = $_GET['delete'];
|
||||
// further check if the current user is the owner of the community
|
||||
$delete_id = $_GET['delete'];
|
||||
$stmt = $pdo->prepare('DELETE FROM communities WHERE id = ? AND leader_id = ?');
|
||||
$stmt->execute([$community_id_to_delete, $user_id]);
|
||||
$stmt->execute([$delete_id, $user_id]);
|
||||
header('Location: manage_communities.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Handle form submission for creating/editing
|
||||
$name = $description = '';
|
||||
$errors = [];
|
||||
$edit_id = null;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$edit_id = $_POST['edit_id'] ?? null;
|
||||
|
||||
if (empty($name)) {
|
||||
$errors[] = 'Community name is required';
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
if ($edit_id) {
|
||||
// Update existing community
|
||||
$stmt = $pdo->prepare('UPDATE communities SET name = ?, description = ? WHERE id = ? AND leader_id = ?');
|
||||
$stmt->execute([$name, $description, $edit_id, $user_id]);
|
||||
} else {
|
||||
// Create new community
|
||||
$stmt = $pdo->prepare('INSERT INTO communities (name, description, leader_id) VALUES (?, ?, ?)');
|
||||
$stmt->execute([$name, $description, $user_id]);
|
||||
}
|
||||
header('Location: manage_communities.php');
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
$errors[] = 'Database error: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch community to edit if an id is passed
|
||||
// Handle editing a community
|
||||
if (isset($_GET['edit'])) {
|
||||
$edit_id = $_GET['edit'];
|
||||
$stmt = $pdo->prepare('SELECT * FROM communities WHERE id = ? AND leader_id = ?');
|
||||
@ -78,12 +76,13 @@ if (isset($_GET['edit'])) {
|
||||
}
|
||||
|
||||
|
||||
// Fetch all communities led by the user
|
||||
$stmt = $pdo->prepare('SELECT * FROM communities WHERE leader_id = ? ORDER BY created_at DESC');
|
||||
// Fetch communities led by the user
|
||||
$stmt = $pdo->prepare('SELECT * FROM communities WHERE leader_id = ? ORDER BY name');
|
||||
$stmt->execute([$user_id]);
|
||||
$communities = $stmt->fetchAll();
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@ -91,56 +90,89 @@ $communities = $stmt->fetchAll();
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Manage Communities - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<?php include 'includes/header.php'; ?>
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<i class="fas fa-cubes me-2"></i>Community Hub
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link active" href="manage_communities.php">Manage</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="flex-grow-1">
|
||||
<section class="container mt-5">
|
||||
<h1 class="text-center mb-4">Manage Communities</h1>
|
||||
|
||||
<div class="card card-neon mb-4">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title"><?php echo $edit_id ? 'Edit Community' : 'Create a New Community'; ?></h2>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="manage_communities.php" method="POST">
|
||||
<input type="hidden" name="edit_id" value="<?php echo $edit_id; ?>">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Community Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="3" required><?php echo htmlspecialchars($description); ?></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-gradient"><?php echo $edit_id ? 'Save Changes' : 'Create Community'; ?></button>
|
||||
<?php if ($edit_id): ?>
|
||||
<a href="manage_communities.php" class="btn btn-secondary">Cancel Edit</a>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
</div>
|
||||
<div class="text-center mb-5">
|
||||
<h1 class="display-4 text-white">Manage Communities</h1>
|
||||
<p class="lead text-white-50">Create, edit, and manage your communities.</p>
|
||||
</div>
|
||||
|
||||
<h2 class="mb-3">Your Communities</h2>
|
||||
<div class="list-group">
|
||||
<?php if (empty($communities)): ?>
|
||||
<p>You have not created any communities yet.</p>
|
||||
<div class="form-container mb-5">
|
||||
<h2 class="text-white mb-4"><?php echo $edit_id ? 'Edit Community' : 'Create a New Community'; ?></h2>
|
||||
<?php if (!empty($errors)):
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error):
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="manage_communities.php" method="POST">
|
||||
<input type="hidden" name="edit_id" value="<?php echo $edit_id; ?>">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label text-white-50">Community Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="description" class="form-label text-white-50">Description</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="3" required><?php echo htmlspecialchars($description); ?></textarea>
|
||||
</div>
|
||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||
<?php if ($edit_id):
|
||||
<a href="manage_communities.php" class="btn btn-secondary me-md-2">Cancel Edit</a>
|
||||
<?php endif; ?>
|
||||
<button type="submit" class="btn btn-primary"><?php echo $edit_id ? 'Save Changes' : 'Create Community'; ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h2 class="text-white mb-4">Your Communities</h2>
|
||||
<div class="row">
|
||||
<?php if (empty($communities)):
|
||||
<div class="col">
|
||||
<div class="form-container text-center">
|
||||
<p class="lead text-white-50">You have not created any communities yet.</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($communities as $community):
|
||||
<div class="list-group-item">
|
||||
<h5><?php echo htmlspecialchars($community['name']); ?></h5>
|
||||
<p><?php echo htmlspecialchars($community['description']); ?></p>
|
||||
<div>
|
||||
<a href="manage_communities.php?edit=<?php echo $community['id']; ?>" class="btn btn-sm btn-outline-primary">Edit</a>
|
||||
<a href="manage_communities.php?delete=<?php echo $community['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are you sure you want to delete this community?');">Delete</a>
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card bg-white-10 text-white h-100">
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h5 class="card-title"><?php echo htmlspecialchars($community['name']); ?></h5>
|
||||
<p class="card-text flex-grow-1"><?php echo htmlspecialchars($community['description']); ?></p>
|
||||
<div class="mt-auto">
|
||||
<a href="manage_communities.php?edit=<?php echo $community['id']; ?>" class="btn btn-sm btn-outline-light me-2"><i class="fas fa-edit me-1"></i>Edit</a>
|
||||
<a href="manage_communities.php?delete=<?php echo $community['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are you sure you want to delete this community?');"><i class="fas fa-trash me-1"></i>Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
@ -149,8 +181,12 @@ $communities = $stmt->fetchAll();
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
64
messages.php
64
messages.php
@ -33,20 +33,24 @@ $stmt->execute([$_SESSION['user_id']]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Messages</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
<title>Messages - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</a>
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<i class="fas fa-cubes me-2"></i>Community Hub
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
@ -54,8 +58,10 @@ $user_role = $stmt->fetchColumn();
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php">Proposals</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="messages.php">Messages</a></li>
|
||||
@ -65,25 +71,41 @@ $user_role = $stmt->fetchColumn();
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4 flex-grow-1">
|
||||
<h2>Messages</h2>
|
||||
<div class="list-group">
|
||||
<?php foreach ($conversations as $convo): ?>
|
||||
<a href="conversation.php?with=<?php echo $convo['user_id']; ?>" class="list-group-item list-group-item-action">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1"><?php echo htmlspecialchars($convo['username']); ?></h5>
|
||||
<small><?php echo date('M j, Y, g:i a', strtotime($convo['created_at'])); ?></small>
|
||||
<main class="container mt-5 flex-grow-1">
|
||||
<div class="text-center mb-5">
|
||||
<h1 class="display-4 text-white">Messages</h1>
|
||||
<p class="lead text-white-50">Your recent conversations.</p>
|
||||
</div>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-10">
|
||||
<?php if (empty($conversations)): ?>
|
||||
<div class="form-container text-center">
|
||||
<p class="lead text-white-50">You have no conversations yet.</p>
|
||||
</div>
|
||||
<p class="mb-1"><?php echo htmlspecialchars(substr($convo['message'], 0, 100)); ?>...</p>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<?php foreach ($conversations as $convo): ?>
|
||||
<div class="message-item">
|
||||
<a href="conversation.php?with=<?php echo $convo['user_id']; ?>">
|
||||
<div class="message-item-header">
|
||||
<h5 class="text-white mb-0"><?php echo htmlspecialchars($convo['username']); ?></h5>
|
||||
<small class="text-white-50"><?php echo date('M j, Y, g:i a', strtotime($convo['created_at'])); ?></small>
|
||||
</div>
|
||||
<p class="text-white-50 mb-0"><?php echo htmlspecialchars(substr($convo['message'], 0, 100)); ?>...</p>
|
||||
</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -43,12 +43,14 @@ $user_role = $stmt->fetchColumn();
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php">Proposals</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
<li class="nav-item"><a class.="nav-link" href="logout.php">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
61
proposal.php
61
proposal.php
@ -18,7 +18,7 @@ if (!$proposal_id) {
|
||||
$pdo = db();
|
||||
|
||||
// Fetch proposal data
|
||||
$stmt = $pdo->prepare("SELECT p.*, u.username FROM proposals p JOIN users u ON p.user_id = u.id WHERE p.id = ?");
|
||||
$stmt = $pdo->prepare("SELECT p.*, u.name, c.id as community_id FROM proposals p JOIN users u ON p.user_id = u.id JOIN communities c ON p.community_id = c.id WHERE p.id = ?");
|
||||
$stmt->execute([$proposal_id]);
|
||||
$proposal = $stmt->fetch();
|
||||
|
||||
@ -34,20 +34,24 @@ $stmt->execute([$_SESSION['user_id']]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Proposal Details</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
<title>Proposal Details - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</a>
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<i class="fas fa-cubes me-2"></i>Community Hub
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
@ -55,8 +59,11 @@ $user_role = $stmt->fetchColumn();
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="discussions.php?community_id=<?php echo $proposal['community_id']; ?>">Discussions</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php?community_id=<?php echo $proposal['community_id']; ?>">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="proposals.php?community_id=<?php echo $proposal['community_id']; ?>">Proposals</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
@ -66,23 +73,37 @@ $user_role = $stmt->fetchColumn();
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4 flex-grow-1">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2><?php echo htmlspecialchars($proposal['title']); ?></h2>
|
||||
<main class="container mt-5 flex-grow-1">
|
||||
<div class="proposal-details-container">
|
||||
<div class="proposal-details-header">
|
||||
<h1 class="display-4 text-white"><?php echo htmlspecialchars($proposal['title']); ?></h1>
|
||||
<p class="lead text-white-50">Submitted by <?php echo htmlspecialchars($proposal['name']); ?></p>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="card-text"><?php echo nl2br(htmlspecialchars($proposal['description'])); ?></p>
|
||||
<p><strong>Author:</strong> <?php echo htmlspecialchars($proposal['username']); ?></p>
|
||||
<p><strong>Status:</strong> <?php echo htmlspecialchars($proposal['status']); ?></p>
|
||||
<div class="proposal-details-body text-white">
|
||||
<p class="fs-5"><?php echo nl2br(htmlspecialchars($proposal['description'])); ?></p>
|
||||
<hr class="border-light">
|
||||
<div class="d-flex justify-content-between align-items-center mt-4">
|
||||
<p class="fs-5 mb-0"><strong>Status:</strong></p>
|
||||
<?php
|
||||
$status_class = 'proposal-status-pending';
|
||||
if ($proposal['status'] === 'approved') {
|
||||
$status_class = 'proposal-status-approved';
|
||||
} elseif ($proposal['status'] === 'rejected') {
|
||||
$status_class = 'proposal-status-rejected';
|
||||
}
|
||||
?>
|
||||
<span class="proposal-status <?php echo $status_class; ?>"><?php echo htmlspecialchars(ucfirst($proposal['status'])); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
103
proposals.php
103
proposals.php
@ -7,32 +7,53 @@ if (!isset($_SESSION['user_id'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$community_id = $_GET['community_id'] ?? null;
|
||||
|
||||
// Fetch all proposals
|
||||
$stmt = $pdo->query("SELECT p.*, u.username FROM proposals p JOIN users u ON p.user_id = u.id ORDER BY p.created_at DESC");
|
||||
$proposals = $stmt->fetchAll();
|
||||
if (!$community_id) {
|
||||
echo "Community ID is required.";
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('SELECT * FROM communities WHERE id = ?');
|
||||
$stmt->execute([$community_id]);
|
||||
$community = $stmt->fetch();
|
||||
|
||||
if (!$community) {
|
||||
echo "Community not found.";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fetch user role
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$stmt->execute([$user_id]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
|
||||
// Fetch proposals for the community
|
||||
$stmt = $pdo->prepare('SELECT p.*, u.name as user_name FROM proposals p JOIN users u ON p.user_id = u.id WHERE p.community_id = ? ORDER BY p.created_at DESC');
|
||||
$stmt->execute([$community_id]);
|
||||
$proposals = $stmt->fetchAll();
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Proposals</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
<title><?php echo htmlspecialchars($community['name']); ?> Proposals - Community Hub</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="background-animation"></div>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="index.php">Community Hub</a>
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<i class="fas fa-cubes me-2"></i>Community Hub
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
@ -40,8 +61,11 @@ $user_role = $stmt->fetchColumn();
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="discussions.php?community_id=<?php echo $community_id; ?>">Discussions</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="events.php?community_id=<?php echo $community_id; ?>">Events</a></li>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="proposals.php?community_id=<?php echo $community_id; ?>">Proposals</a></li>
|
||||
<?php if ($user_role === 'leader'): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
@ -51,29 +75,48 @@ $user_role = $stmt->fetchColumn();
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container mt-4 flex-grow-1">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h2>Proposals</h2>
|
||||
<a href="create_proposal.php" class="btn btn-primary">New Proposal</a>
|
||||
<main class="container mt-5 flex-grow-1">
|
||||
<div class="d-flex justify-content-between align-items-center mb-5">
|
||||
<div>
|
||||
<h1 class="display-4 text-white">Proposals in <?php echo htmlspecialchars($community['name']); ?></h1>
|
||||
<p class="lead text-white-50">Shape the future of your community.</p>
|
||||
</div>
|
||||
<a href="create_proposal.php?community_id=<?php echo $community_id; ?>" class="btn btn-primary btn-lg"><i class="fas fa-plus me-2"></i>New Proposal</a>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<?php foreach ($proposals as $proposal): ?>
|
||||
<a href="proposal.php?id=<?php echo $proposal['id']; ?>" class="list-group-item list-group-item-action">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1"><?php echo htmlspecialchars($proposal['title']); ?></h5>
|
||||
<small><?php echo date('M j, Y', strtotime($proposal['created_at'])); ?></small>
|
||||
<div class="row">
|
||||
<?php if (empty($proposals)): ?>
|
||||
<div class="col">
|
||||
<div class="form-container text-center">
|
||||
<p class="lead text-white-50">No proposals yet. Be the first to create one!</p>
|
||||
</div>
|
||||
<p class="mb-1"><?php echo htmlspecialchars(substr($proposal['description'], 0, 100)); ?>...</p>
|
||||
<small>By <?php echo htmlspecialchars($proposal['username']); ?></small>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($proposals as $proposal): ?>
|
||||
<div class="col-lg-6">
|
||||
<div class="proposal-card">
|
||||
<a href="proposal.php?id=<?php echo $proposal['id']; ?>">
|
||||
<div class="proposal-card-body">
|
||||
<h5 class="card-title text-white"><?php echo htmlspecialchars($proposal['title']); ?></h5>
|
||||
<p class="card-text text-white-50"><?php echo htmlspecialchars(substr($proposal['description'], 0, 150)); ?>...</p>
|
||||
</div>
|
||||
<div class="proposal-card-footer">
|
||||
<small>By <?php echo htmlspecialchars($proposal['user_name']); ?></small>
|
||||
<small><?php echo date('M j, Y', strtotime($proposal['created_at'])); ?></small>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="bg-dark text-white text-center p-3 mt-auto">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
<footer class="footer">
|
||||
<div class="container text-center">
|
||||
<p>© <?php echo date("Y"); ?> Community Hub. All Rights Reserved.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@ -103,6 +103,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
|
||||
|
||||
@ -1,69 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
FILES=("discussions.php" "discussion.php" "edit_discussion.php" "edit_reply.php" "event.php" "events.php" "profile.php" "proposal.php" "proposals.php" "messages.php" "conversation.php")
|
||||
|
||||
PHP_SNIPPET_TO_REPLACE="if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}"
|
||||
|
||||
PHP_SNIPPET_REPLACEMENT="if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fetch user role if logged in
|
||||
|
||||
$user_role = null;
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('SELECT role FROM users WHERE id = ?');
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$user_role = $stmt->fetchColumn();
|
||||
}"
|
||||
|
||||
HTML_SNIPPET_TO_REPLACE='<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>'
|
||||
|
||||
HTML_SNIPPET_REPLACEMENT='<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === "leader"): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>'
|
||||
|
||||
for FILE in "${FILES[@]}"
|
||||
do
|
||||
# Use a temporary file to avoid issues with sed -i
|
||||
sed "s|$PHP_SNIPPET_TO_REPLACE|$PHP_SNIPPET_REPLACEMENT|" "$FILE" > "${FILE}.tmp"
|
||||
mv "${FILE}.tmp" "$FILE"
|
||||
|
||||
sed "s|$HTML_SNIPPET_TO_REPLACE|$HTML_SNIPPET_REPLACEMENT|" "$FILE" > "${FILE}.tmp"
|
||||
mv "${FILE}.tmp" "$FILE"
|
||||
done
|
||||
|
||||
# Special cases with active class
|
||||
|
||||
HTML_SNIPPET_TO_REPLACE_ACTIVE_COMMUNITIES='<li class="nav-item"><a class="nav-link active" aria-current="page" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>'
|
||||
|
||||
HTML_SNIPPET_REPLACEMENT_ACTIVE_COMMUNITIES='<li class="nav-item"><a class="nav-link active" aria-current="page" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === "leader"): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link" href="profile.php">Profile</a></li>'
|
||||
|
||||
sed "s|$HTML_SNIPPET_TO_REPLACE_ACTIVE_COMMUNITIES|$HTML_SNIPPET_REPLACEMENT_ACTIVE_COMMUNITIES|" "communities.php" > "communities.php.tmp"
|
||||
mv "communities.php.tmp" "communities.php"
|
||||
|
||||
|
||||
HTML_SNIPPET_TO_REPLACE_ACTIVE_PROFILE='<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="profile.php">Profile</a></li>'
|
||||
|
||||
HTML_SNIPPET_REPLACEMENT_ACTIVE_PROFILE='<li class="nav-item"><a class="nav-link" href="communities.php">Communities</a></li>
|
||||
<?php if ($user_role === "leader"): ?>
|
||||
<li class="nav-item"><a class="nav-link" href="manage_communities.php">Manage Communities</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="nav-item"><a class="nav-link active" aria-current="page" href="profile.php">Profile</a></li>'
|
||||
|
||||
sed "s|$HTML_SNIPPET_TO_REPLACE_ACTIVE_PROFILE|$HTML_SNIPPET_REPLACEMENT_ACTIVE_PROFILE|" "profile.php" > "profile.php.tmp"
|
||||
mv "profile.php.tmp" "profile.php"
|
||||
Loading…
x
Reference in New Issue
Block a user