root/de.wbb-security.database.autojoingroup/files/lib/acp/form/DatabaseAutoJoinGroupForm.class.php @ 963

Revision 963, 3.3 kB (checked in by MDMAN, 4 years ago)

Webdisk AdditionalRating?; neue Version --> Edit-Klasse wurde hinzugefügt.

Line 
1<?php
2require_once(WCF_DIR.'lib/acp/form/ACPForm.class.php');
3
4/**
5 * @author              Markus Gerdelmann
6 * @copyright   2005-2009
7 * @package             de.wbb-security.database.autojoingroup
8 */
9class DatabaseAutoJoinGroupForm extends ACPForm {
10
11        public $templateName = 'databaseAutoJoinGroup';
12        public $activeMenuItem = 'wcf.acp.menu.link.content.database.autojoingroup.view';
13        public $neededPermissions = 'admin.database.canViewAutoJoinGroup';
14       
15        private $groups = array();
16        private $joins = array();
17        private $groupID = 0;
18        private $uploads = '';
19               
20        /**
21         * @see Form::readFormParameters()
22         */
23        public function readFormParameters() {
24                parent::readFormParameters();
25
26                if (isset($_POST['groupID'])) {
27                        $this->groupID = intval($_POST['groupID']);
28                }
29                if (isset($_POST['uploads'])) {
30                        $this->uploads = intval($_POST['uploads']);
31                }               
32        }       
33       
34        /**
35         * @see Form::validate()
36         */
37        public function validate() {
38                parent::validate();
39               
40                if ($this->groupID == 0){
41                        throw new UserInputException('groupID');
42                }
43               
44                if (empty($this->uploads) || $this->uploads != intval($this->uploads) || intval($this->uploads) < 0) {
45                        throw new UserInputException('uploads');
46                }               
47        }
48       
49        /**
50         * @see Page::readData()
51         */
52        public function readData() {
53                parent::readData();
54               
55                // Hier werden alle Benutzergruppen geladen.
56                $sql = "SELECT groupID, groupName, groupType
57                                FROM `wcf".WCF_N."_group`
58                                ";
59               
60                $res = WCF::getDB()->sendQuery($sql);
61               
62                while ($row = WCF::getDB()->fetchArray($res)) {
63                       
64                        if($row['groupType'] == Group::EVERYONE || $row['groupType'] == Group::GUESTS || $row['groupType'] == Group::USERS) { continue; };
65                       
66                        if (Group::isAccessibleGroup($row['groupID'])) {
67                                $this->groups[] = $row;
68                        }
69                }               
70               
71                // Hier werden die schon vorhandenen AutoJoinGroups geladen.
72                $sql = "SELECT `a`.*, `b`.`groupName`, `b`.`groupType`
73                                FROM `wcf".WCF_N."_database_autojoingroup` AS `a`
74                                LEFT JOIN `wcf".WCF_N."_group` AS `b`
75                                        ON ( `a`.`groupID` = `b`.`groupID`)
76                                ORDER BY `uploads` ASC
77                                ";
78       
79                $res = WCF::getDB()->sendQuery($sql);
80               
81                while ($row = WCF::getDB()->fetchArray($res)) {
82                       
83                        if($row['groupType'] == Group::EVERYONE || $row['groupType'] == Group::GUESTS || $row['groupType'] == Group::USERS) { continue; };
84                       
85                        $row['editable'] = '0';
86                       
87                        if (Group::isAccessibleGroup($row['groupID'])) {
88                                $row['editable'] = '1';
89                        }
90                       
91                        $this->joins[] = $row;
92                }                                       
93        }
94       
95        /**
96         * @see Form::save()
97         */
98        public function save() {
99                parent::save();
100               
101                if (Group::isAccessibleGroup($this->groupID)) {         
102                        $sql = "INSERT INTO `wcf".WCF_N."_database_autojoingroup` (`joinID`, `groupID`, `uploads`)
103                        VALUES ('', '".escapeString($this->groupID)."', '".escapeString($this->uploads)."')
104                        ";
105                       
106                        WCF::getDB()->sendQuery($sql);
107                               
108                        // show success.
109                        WCF::getTPL()->assign(array(
110                                'success' => true
111                        ));             
112                }               
113        }
114       
115        /**
116         * @see Page::show()
117         */
118        public function show() {
119                parent::show();
120               
121        }
122       
123        /**
124         * @see Page::assignVariables()
125         */
126        public function assignVariables() {
127                parent::assignVariables();
128               
129                WCF::getTPL()->assign(array(
130               
131                        'groups' => $this->groups,
132                        'joins' => $this->joins,
133                        'uploads' => $this->uploads
134                ));             
135        }
136}
137?>
Note: See TracBrowser for help on using the browser.