-
Notifications
You must be signed in to change notification settings - Fork 1
/
latest-user-activity.php
191 lines (176 loc) · 6.12 KB
/
latest-user-activity.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
<?php
/**
* latest User Activity Page - Shows the latest activity, comments and models uploaded, showing only top 5 for each, pertaining to each individual user.
* Copyright (C) 2011-2012 Betaville
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
?>
<div class='activity-section'>
<?php
$page='profile';
include_once('config.php');
include_once('betaville-functions.php');
$loggedInUser = false;
if(isset($_GET['uName']))
$userName = $_GET['uName'];
else if(isset($_SESSION['username'])){
$userName = $_SESSION['username'];
$loggedInUser = true;
}
else{
header("Location: index.php");
}
//Check its the logged-in user or other user
if($loggedInUser)
echo "<h2>My Latest Activities</h2><br>";
else
echo "<h2>Latest Activities</h2><br>";
// swap to request=proposals or request=versions
// Fetching designs now findbyuser, keep in mind, a huge number of users will be returned with an empty array if you have not uploaded anything
$designRequest = SERVICE_URL.'?section=design&request=findbyuser&user='.$userName.'&excludeempty=1';
$designJSON = file_get_contents($designRequest,0,null,null);
$designOutput = json_decode($designJSON, true);
$designs = $designOutput['designs'];
//This is to echo the total number of models uploaded by the user
$count = 0;
//This is to break the loop after 5 designs
$counter = 0;
foreach($designs as $design) {
$count++;
}
/*
Not sure why this is here.....
//Check if you retrieve uName or username
if($userName = $_SESSION['username'])
$display = $count.' Models loaded by you';
else
$display = $count.' Models loaded by '.$userName;
if($count>0)
echo '<strong>'.$display.'</strong><br><br>';
else
{
//Check if you retrieve uName or username
if(isset($_GET['uName']))
$display = 'No Models uploaded by '.$userName;
echo '<strong>'.$display.'</strong><br><br>';
}
*/
if($count>0){
//Check its the logged-in user or other user
if($loggedInUser)
$display = $count.' Models loaded by you';
else
$display = $count.' Models loaded by '.$userName;
}
else{
//Check its the logged-in user or other user
if($userName == $_SESSION['username'])
$display = 'No Models loaded by you';
else
$display = 'No Models loaded by '.$userName;
}
echo '<strong>'.$display.'</strong><br><br>';
foreach($designs as $design){
/* Im not sure if this check is to be done, it is a separate file now change
if(($page=='profile' && $design['user']==$userName))*/
?>
<div class='activity'>
<?php
$counter++;
echo "<a href='design.php?id=".$design['designID']."'>\n";
//Check if image exists on server
$image = checkimage(THUMBNAIL_URL.$design['designID'].'.png');
echo "<a href='design.php?id=".$design['designID']."'>\n";
?>
<img src=<?php echo $image;?> style='background-color: #3e4b71'>
<div class='activity-body'>
<?php
echo '<a href="profile.php?uName='.$design['user'].'"><strong>'.$design['user'].'</a>'.'</strong> uploaded ';
echo '<a href="design.php?id='.$design['designID'].'"><strong>'.$design['name'].'</a>'.'</strong>:';
?>
<span class='content'><?php echo $design['description'] ?></span>
<div class='activity-meta'>
<?php
$updatedtime = fd($design['date']);
timediff($updatedtime);
?>
</div>
</div>
</div>
<?php
//Break loop here after showing 5 designs
if($counter>=5)
break;
}
?>
<br><br>
<?php
// retrieving comments by passing $userName in section activity request myactivity and user = $userName
//Check its the logged-in user or other user
if($loggedInUser)
$commentRequest = SERVICE_URL.'?section=activity&request=myactivity&user='.$userName;
else
$commentRequest = SERVICE_URL.'?section=activity&request=peruseractivity&user='.$userName;
$commentJSON = file_get_contents($commentRequest,0,null,null);
$commentOutput = json_decode($commentJSON, true);
$comments = $commentOutput['comments'];
$commentcount = 0;
//Check if you retrieve uName or username
if(isset($_GET['uName'])) {}
else{
foreach($comments as $comment){
$commentcount++;
}
if($commentcount==0) {
$display = 'No comments by you';
echo '<strong>'.$display.'</strong><br><br>';
}
}
$counter = 0;
foreach($comments as $comment){
$counter++;
$commentDesignRequest = SERVICE_URL.'?section=design&request=findbyid&id='.$comment['designid'];
$commentDesignJSON = file_get_contents($commentDesignRequest,0,null,null);
$commentDesignOutput = json_decode($commentDesignJSON, true);
$commentDesign = $commentDesignOutput['design'];
?>
<div class='activity'>
<?php
echo '<a href="design.php?id='.$commentDesign['designID'].'">';
//Check if image exists on server
$image = checkimage(THUMBNAIL_URL.$commentDesign['designID'].'.png');
echo "<a href='design.php?id=".$commentDesign['designID']."'>\n"; ?>
<img src=<?php echo $image;?> style='background-color: #3e4b71'> </a>
<div class='activity-body'>
<?php
//echo '<a href="profile.php?uName='.$commentDesign['user'].'"><strong>'.$commentDesign['user'].'</a>'.'</strong> commented on ';
echo '<a href="profile.php?uName='.$userName.'"><strong>'.$userName.'</a>'.'</strong> commented on ';
echo '<a href="design.php?id='.$commentDesign['designID'].'"><strong>'.$commentDesign['name'].'</a>'.'</strong>:';
?>
<span class='content'><?php echo $comment['comment'] ?></span>
<div class='activity-meta'>
<?php
$updatedtime = fd($comment['date']);
timediff($updatedtime);
?>
</div>
</div>
</div>
<?php
if($counter>=5)
break;
}
?>
</div>