1: <?php if(!defined('APPLICATION')) exit();
2:
3:
4: 5: 6: 7: 8: 9:
10: class LeaderBoardModule extends Gdn_Module {
11:
12: 13: 14: 15: 16:
17: protected $Title = FALSE;
18:
19:
20: 21: 22: 23: 24:
25: public function __construct($Sender = '') {
26: parent::__construct($Sender);
27: }
28:
29: 30: 31: 32: 33:
34: public function AssetTarget() {
35: return 'Panel';
36: }
37:
38: 39: 40: 41: 42: 43:
44: public function GetData($SlotType = 'a') {
45:
46: $Leaders = Gdn::SQL()
47: ->Select('up.Points as YagaPoints, u.*')
48: ->From('User u')
49: ->Join('UserPoints up', 'u.UserID = up.UserID')
50: ->Where('up.SlotType', $SlotType)
51: ->Where('up.TimeSlot', gmdate('Y-m-d', Gdn_Statistics::TimeSlotStamp($SlotType)))
52: ->Where('up.Source', 'Total')
53: ->OrderBy('up.Points', 'desc')
54: ->Limit(C('Yaga.LeaderBoard.Limit', 10), 0)
55: ->Get()
56: ->Result();
57:
58: $this->Data = $Leaders;
59: switch($SlotType) {
60: case 'a':
61: $this->Title = T('Yaga.LeaderBoard.AllTime');
62: break;
63: case 'w':
64: $this->Title = T('Yaga.LeaderBoard.Week');
65: break;
66: case 'm':
67: $this->Title = T('Yaga.LeaderBoard.Month');
68: break;
69: case 'y':
70: $this->Title = T('Yaga.LeaderBoard.Year');
71: break;
72: }
73:
74: }
75:
76: 77: 78: 79: 80:
81: public function ToString() {
82: if(!$this->Data && !$this->Title) {
83: $this->GetData();
84: }
85:
86: if($this->Visible && count($this->Data)) {
87: $ViewPath = $this->FetchViewLocation('leaderboard', 'yaga');
88: $String = '';
89: ob_start();
90: include ($ViewPath);
91: $String = ob_get_contents();
92: @ob_end_clean();
93: return $String;
94: }
95: return '';
96: }
97:
98: }
99: