forked from opencaching/opencaching-pl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_badges.php
69 lines (50 loc) · 3.11 KB
/
user_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
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
<?php
use src\Models\MeritBadge\MeritBadge;
use src\Controllers\MeritBadgeController;
use src\Models\ApplicationContainer;
require_once (__DIR__.'/lib/common.inc.php');
require_once (__DIR__.'/src/Views/user_badges.inc.php');
global $content_table;
$loggedUser = ApplicationContainer::GetAuthorizedUser();
if (!$loggedUser) {
$target = urlencode(tpl_get_current_page());
tpl_redirect('login.php?target=' . $target);
exit;
}
$tplname = 'user_badges';
if (isset($_REQUEST['user_id'])) {
$userid = $_REQUEST['user_id'];
} else {
$userid = $loggedUser->getUserId();
}
$meritBadgeCtrl = new \src\Controllers\MeritBadgeController;
$userCategories = $meritBadgeCtrl->buildArrayUserCategories($userid);
$content = '';
foreach($userCategories as $oneCategory){
$category_table=mb_ereg_replace('{category}', $oneCategory->getName(), $content_table);
$badgesInCategory = $meritBadgeCtrl->buildArrayUserMeritBadgesInCategory( $userid, $oneCategory->getId() );
$content_badge = '';
foreach($badgesInCategory as $oneBadge){
$element=$content_element;
$element=mb_ereg_replace('{name}', $oneBadge->getOBadge()->getName(), $element);
$element=mb_ereg_replace('{short_desc}', MeritBadge::prepareShortDescription( $oneBadge->getOBadge()->getShortDescription(),
$oneBadge->getNextVal(),
$oneBadge->getCurrVal()),
$element );
$element=mb_ereg_replace('{picture}', $oneBadge->getPicture(), $element );
$element=mb_ereg_replace('{level_name}', $oneBadge->getOLevel()->getLevelName(), $element );
$element=mb_ereg_replace('{badge_id}', $oneBadge->getBadgeId(), $element );
$element=mb_ereg_replace('{user_id}', $userid, $element );
$element=mb_ereg_replace('{curr_val}', $oneBadge->getCurrVal(), $element );
$element=mb_ereg_replace('{progresbar_curr_val}', MeritBadge::getProgressBarCurrValue($oneBadge->getOLevel()->getPrevThreshold(), $oneBadge->getCurrVal(), $oneBadge->getNextVal()), $element );
$element=mb_ereg_replace('{progresbar_next_val}', MeritBadge::getProgressBarValueMax($oneBadge->getOLevel()->getPrevThreshold(), $oneBadge->getNextVal()), $element );
$element=mb_ereg_replace('{next_val}', MeritBadge::prepareTextThreshold($oneBadge->getNextVal()), $element );
$element=mb_ereg_replace('{progresbar_size}', MeritBadge::getBarSize( $oneBadge->getLevelId(), $oneBadge->getOBadge()->getLevelsNumber() ), $element );
$element=mb_ereg_replace('{progresbar_color}', MeritBadge::getColor( $oneBadge->getLevelId(), $oneBadge->getOBadge()->getLevelsNumber() ), $element );
$content_badge.= $element;
}
$content.=mb_ereg_replace('{content_badge_img}', $content_badge, $category_table);
}
$content.="<a class='links' href='user_badges.php?user_id=999999'>[".tr('merit_badge_show_list')."]</a><br><br>";
tpl_set_var( 'content', $content );
tpl_BuildTemplate();