-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevent.php
309 lines (270 loc) · 10.4 KB
/
event.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<?php
/**
* event
*
* @package Delus
* @author Dmitry
*/
// fetch bootloader
require('bootloader.php');
// user access
if (!$system['system_public']) {
user_access();
}
// check event id
if (is_empty($_GET['event_id'])) {
_error(404);
}
try {
// [1] get main event info
$get_event = $db->query(sprintf("SELECT `events`.*, cover_photo.source as event_cover_full, users.user_name, users.user_firstname, users.user_lastname, events_categories.category_name as event_category_name FROM `events` LEFT JOIN posts_photos as cover_photo ON `events`.event_cover_id = cover_photo.photo_id LEFT JOIN events_categories ON `events`.event_category = events_categories.category_id INNER JOIN users ON `events`.event_admin = users.user_id WHERE `events`.event_id = %s", secure($_GET['event_id'])));
if ($get_event->num_rows == 0) {
_error(404);
}
$event = $get_event->fetch_assoc();
/* get event cover */
$event['event_cover'] = ($event['event_cover']) ? $system['system_uploads'] . '/' . $event['event_cover'] : $event['event_cover'];
$event['event_cover_full'] = ($event['event_cover_full']) ? $system['system_uploads'] . '/' . $event['event_cover_full'] : $event['event_cover_full'];
/* check group category */
$event['event_category_name'] = (!$event['event_category_name']) ? __('N/A') : $event['event_category_name']; /* in case deleted by system admin */
/* get the connection */
$event['i_admin'] = $user->check_event_adminship($user->_data['user_id'], $event['event_id']);
$event['i_joined'] = $user->check_event_membership($user->_data['user_id'], $event['event_id']);
/* get event host */
if ($event['event_page_id']) {
$event['event_page'] = $user->get_page($event['event_page_id']);
$event['event_page']['page_picture'] = get_picture($event['event_page']['page_picture'], 'page');
$event['host_name'] = $event['event_page']['page_title'];
$event['host_url'] = $system['system_url'] . '/pages/' . $event['event_page']['page_name'];
} else {
$event['host_name'] = ($system['show_usernames_enabled']) ? $event['user_name'] : $event['user_firstname'] . ' ' . $event['user_lastname'];
$event['host_url'] = $system['system_url'] . '/' . $event['user_name'];
}
/* get chatbox converstaion */
if ($system['chat_enabled'] && $event['chatbox_enabled'] && ($event['i_joined']['is_going'] || $event['i_joined']['is_interested'])) {
$event['chatbox_conversation'] = $user->get_chatbox($event['chatbox_conversation_id']);
}
/* get event posts count */
$event['posts_count'] = $user->get_posts_count($event['event_id'], 'event');
/* get event photos count */
$event['photos_count'] = $user->get_photos_count($event['event_id'], 'event');
/* get event videos count */
if ($system['videos_enabled']) {
$event['videos_count'] = $user->get_videos_count($event['event_id'], 'event');
}
/* get event reviews count */
if ($system['events_reviews_enabled']) {
$event['reviews_count'] = $user->get_reviews_count($event['event_id'], 'event');
}
// [2] get view content
/* check event privacy */
if ($event['event_privacy'] == "secret") {
if (!$event['i_joined'] && !$event['i_admin']) {
if (!$user->_is_admin && !$user->_is_moderator) {
_error(404);
}
}
}
if ($event['event_privacy'] == "closed") {
if (!$event['i_joined'] && !$event['i_admin']) {
if (!$user->_is_admin && !$user->_is_moderator) {
$_GET['view'] = 'about';
}
}
}
switch ($_GET['view']) {
case '':
/* get custom fields */
$smarty->assign('custom_fields', $user->get_custom_fields(["for" => "event", "get" => "profile", "node_id" => $event['event_id']]));
/* get invites */
$event['invites'] = $user->get_event_invites($event['event_id']);
/* get photos */
$event['photos'] = $user->get_photos($event['event_id'], 'event');
/* get [pending] event posts */
if ($event['event_publish_approval_enabled']) {
$get_all = ($event['i_admin']) ? true : false;
$event['pending_posts'] = $user->get_event_pending_posts($event['event_id'], $get_all);
}
/* prepare publisher */
$smarty->assign('feelings', get_feelings());
$smarty->assign('feelings_types', get_feelings_types());
if ($system['colored_posts_enabled']) {
$smarty->assign('colored_patterns', $user->get_posts_colored_patterns());
}
if ($user->_data['can_upload_videos']) {
$smarty->assign('videos_categories', $user->get_categories("posts_videos_categories"));
}
/* check if there is share URL */
if ($_GET['url']) {
$smarty->assign('url', $_GET['url']);
}
/* get pinned post */
$pinned_post = $user->get_post($event['event_pinned_post'], true, false, true);
$smarty->assign('pinned_post', $pinned_post);
/* get posts */
if (isset($_GET['pending'])) {
$get = ($event['i_admin']) ? "posts_event_pending_all" : "posts_event_pending";
} else {
$get = "posts_event";
}
/* newsfeed location filter */
if ($system['newsfeed_location_filter_enabled']) {
// get selected country
if (isset($_GET['country'])) {
/* get selected country */
$selected_country = $user->get_country_by_name($_GET['country']);
/* assign variables */
$smarty->assign('selected_country', $selected_country);
}
}
$posts = ($selected_country) ? $user->get_posts(['country' => $selected_country['country_id'], 'get' => $get, 'id' => $event['event_id']]) : $user->get_posts(['get' => $get, 'id' => $event['event_id']]);
/* assign variables */
$smarty->assign('posts', $posts);
$smarty->assign('get', $get);
/* get ads */
$smarty->assign('ads', $user->ads('events', $event['event_id']));
break;
case 'photos':
/* get photos */
$event['photos'] = $user->get_photos($event['event_id'], 'event');
break;
case 'albums':
/* get albums */
$event['albums'] = $user->get_albums($event['event_id'], 'event');
break;
case 'album':
/* get album */
$album = $user->get_album($_GET['id']);
if (!$album || ($album['event_id'] != $event['event_id'])) {
_error(404);
}
/* assign variables */
$smarty->assign('album', $album);
break;
case 'videos':
/* check if videos enabled */
if (!$system['videos_enabled']) {
_error(404);
}
/* get videos */
$event['videos'] = $user->get_videos($event['event_id'], 'event');
break;
case 'reels':
/* check if reels enabled */
if (!$system['reels_enabled']) {
_error(404);
}
/* get reels */
$event['reels'] = $user->get_reels($event['event_id'], 'event');
break;
case 'products':
/* get content */
if (!$event['needs_subscription']) {
/* get posts (products) */
$posts = $user->get_posts(['get' => 'posts_event', 'id' => $event['event_id'], 'filter' => 'product']);
/* assign variables */
$smarty->assign('posts', $posts);
}
break;
case 'reviews':
/* check if reviews enabled */
if (!$system['events_reviews_enabled']) {
_error(404);
}
/* get reviews */
if ($event['reviews_count'] > 0) {
$event['reviews'] = $user->get_reviews($event['event_id'], 'event');
}
break;
case 'going':
/* get going members */
if ($event['event_going'] > 0) {
$event['members'] = $user->get_event_members($event['event_id'], 'going');
}
$event['total_members'] = $event['event_going'];
break;
case 'interested':
/* get interested members */
if ($event['event_interested'] > 0) {
$event['members'] = $user->get_event_members($event['event_id'], 'interested');
}
$event['total_members'] = $event['event_interested'];
break;
case 'invited':
/* get invited members */
if ($event['event_invited'] > 0) {
$event['members'] = $user->get_event_members($event['event_id'], 'invited');
}
$event['total_members'] = $event['event_invited'];
break;
case 'invites':
/* check if the viewer is a event member */
if (!$event['i_joined']) {
_error(404);
}
/* get invites */
$event['members'] = $user->get_event_invites($event['event_id']);
$event['total_members'] = count($event['members']);
break;
case 'search':
/* get search */
if (isset($_GET['query'])) {
$filter = (isset($_GET['filter'])) ? $_GET['filter'] : 'all';
$posts = $user->get_posts(['get' => 'posts_event', 'id' => $event['event_id'], 'query' => $_GET['query'], 'filter' => $filter]);
/* assign variables */
$smarty->assign('query', htmlentities($_GET['query'], ENT_QUOTES, 'utf-8'));
$smarty->assign('filter', $filter);
$smarty->assign('posts', $posts);
}
break;
case 'settings':
/* check if the viewer is the admin */
if (!$event['i_admin']) {
_error(404);
}
/* get sub_view content */
$sub_view = $_GET['id'];
switch ($sub_view) {
case '':
/* get events categories */
$smarty->assign('categories', $user->get_categories("events_categories"));
/* get countries if not defined */
if (!$countries) {
$smarty->assign('countries', $user->get_countries());
}
/* get custom fields */
$smarty->assign('custom_fields', $user->get_custom_fields(["for" => "event", "get" => "settings", "node_id" => $event['event_id']]));
break;
case 'delete':
break;
default:
_error(404);
break;
}
/* assign variables */
$smarty->assign('sub_view', $sub_view);
break;
case 'about':
/* check if the viewer is a event member */
if ($event['i_joined']) {
_error(404);
}
break;
default:
_error(404);
break;
}
// recent rearches
if (isset($_GET['ref']) && $_GET['ref'] == "qs") {
$user->set_search_log($event['event_id'], 'event');
}
} catch (Exception $e) {
_error(__("Error"), $e->getMessage());
}
// page header
page_header($event['event_title'], $event['event_description'], $event['event_cover']);
// assign variables
$smarty->assign('event', $event);
$smarty->assign('view', $_GET['view']);
// page footer
page_footer('event');