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

Revision 985, 3.6 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 DatabaseAutoJoinGroupEditForm extends ACPForm {
10
11        public $templateName = 'databaseAutoJoinGroupEdit';
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 $joinID = 0;
18        public $edit = 0;
19        public $groupID = 0;
20        public $uploads = '';
21        public $groupName = '';
22               
23        /**
24         * @see Form::readFormParameters()
25         */
26        public function readFormParameters() {
27                parent::readFormParameters();
28
29                if (isset($_POST['groupID'])) {
30                        $this->groupID = intval($_POST['groupID']);
31                }
32               
33                if (isset($_POST['uploads'])) {
34                        $this->uploads = intval($_POST['uploads']);
35                }
36
37                if (isset($_POST['joinID']))    {
38                        $this->joinID = intval($_POST['joinID']);
39                }       
40        }
41       
42        /**
43         * @see Page::readParameters()
44         */
45        public function readParameters() {
46                parent::readParameters();
47               
48                if (isset($_REQUEST['joinID'])) {
49                        $this->joinID = intval($_REQUEST['joinID']);
50                }
51        }
52       
53        /**
54         * @see Form::validate()
55         */
56        public function validate() {
57                parent::validate();
58               
59                if ($this->groupID == 0){
60                        throw new UserInputException('groupID');
61                }
62               
63                if (empty($this->uploads) || $this->uploads != intval($this->uploads) || intval($this->uploads) < 0) {
64                        throw new UserInputException('uploads');
65                }
66
67                if ($this->joinID == 0){
68                        throw new IllegalLinkException();
69                }       
70        }
71       
72        /**
73         * @see Page::readData()
74         */
75        public function readData() {
76                parent::readData();
77               
78                // Hier werden alle Benutzergruppen geladen.
79                $sql = "SELECT groupID, groupName, groupType
80                                FROM `wcf".WCF_N."_group`
81                                ";
82               
83                $res = WCF::getDB()->sendQuery($sql);
84               
85                while ($row = WCF::getDB()->fetchArray($res)) {
86                       
87                        if($row['groupType'] == Group::EVERYONE || $row['groupType'] == Group::GUESTS || $row['groupType'] == Group::USERS) { continue; };
88                       
89                        if (Group::isAccessibleGroup($row['groupID'])) {
90                                $this->groups[] = $row;
91                        }
92                }
93
94                // Hier wird die zu editierende Regel geladen   
95                $sql = "SELECT `a`.*, `b`.`groupName`
96                                FROM `wcf".WCF_N."_database_autojoingroup` AS `a`
97                                LEFT JOIN `wcf".WCF_N."_group` AS `b`
98                                        ON ( `a`.`groupID` = `b`.`groupID`)
99                                WHERE `a`.`joinID` = '".$this->joinID."'
100                                ";
101               
102                $res = WCF::getDB()->sendQuery($sql);
103       
104                while ($row = WCF::getDB()->fetchArray($res)) {
105                        $this->joins[] = $row;
106                        $this->uploads = $row['uploads'];
107                        $this->groupName = $row['groupName'];
108                }                               
109        }
110       
111        /**
112         * @see Form::save()
113         */
114        public function save() {
115                parent::save();
116               
117                if (Group::isAccessibleGroup($this->groupID)) {
118                        $sql = "UPDATE `wcf".WCF_N."_database_autojoingroup`
119                                        SET `groupID` = '".escapeString($this->groupID)."',
120                                                `uploads` = '".escapeString($this->uploads)."'
121                                        WHERE `joinID` = '".escapeString($this->joinID)."'
122                                        ";
123                       
124                        WCF::getDB()->sendQuery($sql);
125                       
126                        // show success.
127                        WCF::getTPL()->assign(array(
128                                'success' => true
129                        ));                             
130                }       
131        }
132       
133        /**
134         * @see Page::show()
135         */
136        public function show() {
137                parent::show();
138               
139        }
140       
141        /**
142         * @see Page::assignVariables()
143         */
144        public function assignVariables() {
145                parent::assignVariables();
146               
147                WCF::getTPL()->assign(array(
148               
149                        'groups' => $this->groups,
150                        'joins' => $this->joins,
151                        'uploads' => $this->uploads,
152                        'groupName' => $this->groupName,
153                        'joinID' => $this->joinID
154                ));             
155        }
156}
157?>
Note: See TracBrowser for help on using the browser.