-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_project.php
221 lines (190 loc) · 6.88 KB
/
view_project.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
error_reporting(E_ALL ^ E_NOTICE);
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
if(!isUserLoggedIn()) { header("Location: login.php"); die(); }
$id = $_GET['id'];
$proj_id = $id;
$sql="SELECT * FROM project WHERE proj_id='$proj_id'";
$mysqli_result = mysqli_query($mysqli, $sql);
//retrieve to_id
?>
<!DOCTYPE html>
<head>
<title><?php echo $loggedInUser->username." - Colony"; ?></title>
<link rel="stylesheet" type="text/css" href="assets/css/main.css">
<style>
#acc_p{
align-items: center;
width: 200px;
height: 200px;
border-radius: 50%;
background-color: grey;
margin-left: 85px;
margin-top: 20px;
}
#regbox{
margin-top: 100px;
}
#error{
padding-top: 25px;
text-align: center;
color: red;
overflow: hidden;
}
body{
color: #000;
}
#error li{
list-style: none;
}
h2{
padding-left: 20px;
}
form{
margin-top: 20px;
}
.title{
text-align: center;
color:#031d74;
font-size: 35px;
font-weight: 800;
}
.des{
color:#315b9a;
margin-left: 15px;
font-size:18px
}
.tm{
margin-left: 15px;
color:#3c4869;
font-size:15px
}
.author{
color: #290587;
margin-left: 22px;
font-size:15px
}
.row1{
text-align: center;
margin-left: 49px;
border-radius: 8px;
display: block;
margin-top: 10px;
width: 92%;
height: auto;
}
.title input{
font-size: 10px;
padding-bottom: -10px;
margin-top: 30px;
}
</style>
</head>
<body>
<body class="subpage">
<!-- Header -->
<header id="header">
<div class="inner">
<a href="index.php" class="logo">Colony</a>
<nav id="nav">
<a href="home.php">Home</a>
<a href="add_event.php">Add a event</a>
<a href="account.php"><?php echo $loggedInUser->username; ?></a>
<a href="user_settings.php">Update Profile</a>
<a href="logout.php">Logout</a>
</nav>
<a href="#navPanel" class="navPanelToggle"><span class="fa fa-bars"></span></a>
</div>
</header>
<?php
while($rows = mysqli_fetch_assoc($mysqli_result)){
$event_type = $rows['event_type'];
$proj_id = $rows['proj_id'];
$title = $rows['title'];
$description = $rows['description'];
$team_limit = $rows['team_limit'];
$author = $rows['author'];
echo "<div class='row1'>";
echo "<font class='title'>".$title."<br />";
echo "<font class='des'>"."Description: ".$description."<br />";
echo "<font class='even'>"."Event type : ".$event_type."<br />";
//$proj = explode("0",$proj_id);
$sql2="SELECT * FROM team_mem WHERE proj_id='$proj_id'";
$mysqli_result = mysqli_query($mysqli, $sql2);
echo "<font class='tm'>"."Team Members: </font>";
while($rows = mysqli_fetch_assoc($mysqli_result)){
$mem = $rows['mem1'];
echo "<a href='view_user.php?id=".$loggedInUser->user_id."'>".$mem.",</a>";
}
echo "<br /><font class='author'>"."Event created by : ".$author."<br />";
echo "<form action='view_project.php?id=".$proj_id."' method='post'><center><input onclick='this.disabled=TRUE' class='special button' type='submit' value='JOIN GROUP +' name='join_event'></center></form><br />";
echo "</div>";
}
$sql12 = "SELECT * FROM group_users WHERE user_name='$author'";
$result = mysqli_query($mysqli, $sql12);
while($rows = mysqli_fetch_assoc($result)){
$to_id = $rows["id"];
}
if($_POST['join_event']){
$sql = "INSERT INTO send_request (proj_id, from_id, from_user, to_id, to_user, sent, accepted, not_accepted)
VALUES('$id', '$loggedInUser->user_id', '$loggedInUser->username', '$to_id', '$author', '1', '0', '0')";
if ($mysqli->query($sql) === TRUE) {
// $sql123 = "SELECT * FROM send_request WHERE from_id='$loggedInUser->user_id'";
// $result123 = mysqli_query($mysqli, $sql123);
//
// // output data of each row
// while($row = mysqli_fetch_assoc($result123)) {
// $sent = $row['sent'];
// echo $sent;
// }
// if($sent == 1){
// echo "Request sent to ".$author;
// }
}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
// $sql123 = "SELECT * FROM send_request WHERE from_id='$loggedInUser->user_id'";
// $result123 = mysqli_query($mysqli, $sql123);
// while($rows = mysqli_fetch_assoc($result123)){
// $sent = $rows["sent"];
// echo $sent;
// if($sent == '1'){
// echo "Request sent to ".$author;
// }
// else{
// echo "<form action='view_project.php?id=".$proj_id."' method='post'><center><input class='special button' type='submit' value='JOIN GROUP +' name='join_event'></center></form><br />";
// }
//
// }
}
$new = "SELECT * FROM team_mem where proj_id='$id'";
$result = mysqli_query($mysqli, $new);
while($rows = mysqli_fetch_assoc($result)){
$projid = $rows['proj_id'];
$member = $rows['mem1'];
}
$new12 = "SELECT * FROM project where proj_id='$id'";
$result = mysqli_query($mysqli, $new12);
while($rows = mysqli_fetch_assoc($result)){
$author2 = $rows['author'];
}
$_SESSION["proj_id"] = $projid;
$_SESSION["mem"] = $member;
$_SESSION["username"] = $loggedInUser->username;
if($member == $loggedInUser->username || $author2 == $loggedInUser->username){
echo '<center><iframe src="cha/index.php" width=80% height="700px"></iframe></center>';
}
else{
echo "No access";
}
?>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
<script src="assets/js/reg.js"></script>
</body>
</html>