1: <?php if(!defined('APPLICATION')) exit();
2:
3:
4: 5: 6: 7: 8: 9:
10: class BadgesController extends Gdn_Controller {
11:
12: 13: 14: 15:
16: public $Uses = array('BadgeModel', 'BadgeAwardModel');
17:
18: 19: 20: 21:
22: public function Initialize() {
23: parent::Initialize();
24: $this->Application = 'Yaga';
25: $this->Head = new HeadModule($this);
26: $this->AddJsFile('jquery.js');
27: $this->AddJsFile('jquery-ui.js');
28: $this->AddJsFile('jquery.livequery.js');
29: $this->AddJsFile('jquery.popup.js');
30: $this->AddJsFile('global.js');
31: $this->AddCssFile('style.css');
32: $this->AddCssFile('badges.css');
33: $this->AddModule('BadgesModule');
34: $Module = new LeaderBoardModule();
35: $Module->GetData('w');
36: $this->AddModule($Module);
37: $Module = new LeaderBoardModule();
38: $this->AddModule($Module);
39: }
40:
41: 42: 43:
44: public function Index() {
45:
46: $this->All();
47: }
48:
49: 50: 51:
52: public function All() {
53: $this->Title(T('Yaga.AllBadges'));
54:
55: $UserID = Gdn::Session()->UserID;
56:
57:
58: $AllBadges = $this->BadgeModel->GetWithEarned($UserID);
59:
60: $this->SetData('Badges', $AllBadges);
61:
62:
63: $this->Render('all');
64: }
65:
66: 67: 68: 69: 70: 71: 72:
73: public function Detail($BadgeID, $Slug = NULL) {
74: $UserID = Gdn::Session()->UserID;
75: $Badge = $this->BadgeModel->GetByID($BadgeID);
76: $AwardCount = $this->BadgeAwardModel->GetCount($BadgeID);
77: $UserBadgeAward = $this->BadgeAwardModel->Exists($UserID, $BadgeID);
78: $RecentAwards = $this->BadgeAwardModel->GetRecent($BadgeID);
79:
80: if(!$Badge) {
81: throw NotFoundException('Badge');
82: }
83:
84: $this->SetData('AwardCount', $AwardCount);
85: $this->SetData('RecentAwards', $RecentAwards);
86: $this->SetData('UserBadgeAward', $UserBadgeAward);
87: $this->SetData('Badge', $Badge);
88:
89: $this->Title(T('Yaga.ViewBadge') . $Badge->Name);
90:
91: $this->Render();
92: }
93: }
94: