-
Notifications
You must be signed in to change notification settings - Fork 24
/
show_badge.php
43 lines (31 loc) · 1.18 KB
/
show_badge.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
<?php
require_once(__DIR__ . '/global.php');
require_once(__DIR__ . '/classes/User.php');
if (!UserConfig::$enableGamification || !array_key_exists('name', $_GET)) {
header('Location: ' . UserConfig::$USERSROOTURL . '/badges.php');
exit;
}
$user = User::require_login();
$template_info = StartupAPI::getTemplateInfo();
$user_badges = $user->getBadges();
$user_has_this_badge = false;
foreach ($user_badges as $badge_pairs) {
$badge = $badge_pairs[0];
$badge_level = $badge_pairs[1];
if ($badge->getSlug() == $_GET['name']) {
$user_has_this_badge = true;
break;
}
}
if (!$user_has_this_badge) {
header('Location: ' . UserConfig::$USERSROOTURL . '/badges.php');
exit;
}
// setting section value
$template_info['PAGE']['SECTION'] = 'badges';
$template_info['slug'] = $badge->getSlug() . ($badge_level > 1 ? '_' . $badge_level : '');
$template_info['url'] = $badge->getImageURL(UserConfig::$badgeLargeSize, $badge_level);
$template_info['title'] = $badge->getTitle();
$template_info['description'] = $badge->getDescription();
$template_info['call_to_action'] = $badge->getCallToAction($badge_level);
StartupAPI::$template->display('@startupapi/show_badge.html.twig', $template_info);