root/de.inside.wcf.Gewinnspiel/de.inside.wcf.Gewinnspiel/files/lib/acp/page/GewinnspielListPage.class.php @ 519

Revision 519, 2.8 kB (checked in by Tatzelwurm, 5 years ago)

Gewinnspiel für das WCF

  • Property svn:mime-type set to text/plain
  • Property svn:executable set to *
RevLine 
[519]1<?php
2require_once(WCF_DIR.'lib/page/SortablePage.class.php');
3require_once(WCF_DIR.'lib/system/event/EventHandler.class.php');
4
5/**
6 * Gewinnspiel Admin Control Panel.
7 * Listet alle Gewinnspiele auf.
8 * Gewinnspiele knnen hinzugefgt, bearbeitet und gelscht werden.
9 * Liste der User die Teilgenommen haben kann aufgerufen werden
10 *
11 * @author              Robert "Tatzelwurm" Hempel
12 * @copyright   2007/2008 INSIDE das Hrspiel
13 * @license     GNU LGPL http://www.gnu.org/licenses/lgpl.txt
14 * @package             de.inside.wcf.gewinnspiel
15 */
16
17class GewinnspielListPage extends SortablePage {
18
19        public $templateName = 'gewinnspielList';
20        public $itemsPerPage = 10;
21        public $defaultSortField = 'gwsID';
22        public $gwsID;
23        public $list = array();
24        public $gewinnspiele = array();
25        public $gwsIDs;
26       
27        public function readParameters() {
28                parent::readParameters();
29                if (isset($_REQUEST['gwsID'])) $this->gwsID = intval($_REQUEST['gwsID']);
30                if (isset($_REQUEST['action'])) $this->action = $_REQUEST['action'];
31        }
32       
33        public function validateSortField() {
34                parent::validateSortField();
35
36                switch ($this->sortField) {
37                        case 'gwsID':
38                        case 'gwsTitel':
39                        case 'starttime':
40                        case 'timeout': break;
41                        default: $this->sortField = $this->defaultSortField;
42                }
43        }
44       
45        public function readData() {
46                parent::readData();
47                $this->readGewinnspiele();
48        }
49       
50        public function assignVariables() {
51                parent::assignVariables();
52
53                WCF::getTPL()->assign(array(
54                        'gewinnspiele' => $this->gewinnspiele,
55                        'gamescount' => $this->countItems()
56                ));
57        }
58       
59        public function show() {
60                // enable menu item
61                WCFACP::getMenu()->setActiveMenuItem('wcf.acp.menu.link.content.games');
62
63                // check permission
64                WCF::getUser()->checkPermission(array('admin.gewinnspiel.canChangeOptions'));
65               
66                parent::show();
67        }
68       
69        public function countItems() {
70                $sql = "SELECT  COUNT(gwsID) AS gwsIDs
71                                FROM    wcf".WCF_N."_gws_game";
72                $row = WCF::getDB()->getFirstRow($sql);
73
74                return $row['gwsIDs'];
75        }
76       
77        public function countUsers($ID) {
78                $sql = "SELECT  COUNT(userID) AS userIDs
79                                FROM    wcf".WCF_N."_gws_spiel
80                                WHERE   gwsID = $ID";
81                $row = WCF::getDB()->getFirstRow($sql);
82                if (empty($row['userIDs'])) $row['userIDs'] = '';
83                return $row['userIDs'];
84        }
85       
86        protected function readGewinnspiele() {
87                $sql = "SELECT  `gwsID`, `gwsTitel`, `starttime`, `timeout`
88                        FROM            wcf".WCF_N."_gws_game gewinnspiele
89                        ORDER BY        gewinnspiele.".$this->sortField." ".$this->sortOrder."
90                        LIMIT           ".$this->itemsPerPage."
91                        OFFSET          ".(($this->pageNo - 1) * $this->itemsPerPage);
92                $result = WCF::getDB()->sendQuery($sql);
93                while ($row = WCF::getDB()->fetchArray($result)) {
94                        $gewinnspiele =array(
95                                                        'usercount'             => '',
96                                                        );
97                        $row['usercount']       = $this->countUsers($row['gwsID']);
98                        $this->gewinnspiele[] = $row;
99                }
100        }
101}
102?>
Note: See TracBrowser for help on using the browser.