forked from StartupAPI/users
-
Notifications
You must be signed in to change notification settings - Fork 0
/
badges.php
43 lines (28 loc) · 1.03 KB
/
badges.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');
if (!UserConfig::$enableGamification) {
header("HTTP/1.0 404 Not Found");
exit;
}
$user = User::require_login();
$template_info = StartupAPI::getTemplateInfo();
// setting section value
$template_info['PAGE']['SECTION'] = 'badges';
$available_badges = Badge::getAvailableBadges();
$user_badges = $user->getBadges();
foreach ($available_badges as $badge) {
$badge_info = array(
'size' => UserConfig::$badgeListingSize,
);
if (array_key_exists($badge->getID(), $user_badges)) {
$badge_level = $user_badges[$badge->getID()][1];
$badge_info['slug'] = $badge->getSlug();
$badge_info['url'] = $badge->getImageURL(UserConfig::$badgeListingSize, $badge_level);
$badge_info['title'] = $badge->getTitle();
} else {
$badge_info['placeholder_url'] = $badge->getPlaceholderImageURL(UserConfig::$badgeListingSize);
$badge_info['hint'] = $badge->getHint();
}
$template_info['badges'][] = $badge_info;
}
StartupAPI::$template->display('@startupapi/badges.html.twig', $template_info);