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

Revision 985, 3.4 kB (checked in by MDMAN, 4 years ago)

Webdisk AutoJoinGroup?; neue Version --> Es wurden noch kleine Anpassungen vorgenommen.

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        public $groups = array();
16        public $joins = array();
17        public $groupID = 0;
18        public $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                        $this->groupID = 0;
114                        $this->uploads = '';
115                }               
116        }
117       
118        /**
119         * @see Page::show()
120         */
121        public function show() {
122                parent::show();
123               
124        }
125       
126        /**
127         * @see Page::assignVariables()
128         */
129        public function assignVariables() {
130                parent::assignVariables();
131               
132                WCF::getTPL()->assign(array(
133               
134                        'groups' => $this->groups,
135                        'joins' => $this->joins,
136                        'uploads' => $this->uploads,
137                        'groupID' => $this->groupID
138                ));             
139        }
140}
141?>
Note: See TracBrowser for help on using the browser.