root/application.register/files/lib/action/UserGroupOptionsAction.class.php @ 299

Revision 299, 2.2 kB (checked in by d0nut, 5 years ago)

bugfixes

Line 
1<?php
2require_once(WCF_DIR.'lib/action/AbstractAction.class.php');
3require_once(WCF_DIR.'lib/data/user/group/GroupApplicationEditor.class.php');
4
5/**
6 * saves group options
7 *
8 * @author      Markus Gerdelmann, Torben Brodt
9 * @package     de.mdman.application.register
10 * @license     GNU General Public License <http://opensource.org/licenses/gpl-3.0.html>
11 */
12class UserGroupOptionsAction extends AbstractAction {
13        public $displayNotification=0, $emailNotification=0;
14        public $groupID = 0;
15        public $group;
16       
17        /**
18         * @see Action::readParameters()
19         */
20        public function readParameters() {
21                parent::readParameters();
22               
23                if (isset($_POST['groupID'])) $this->groupID = intval($_POST['groupID']);
24                $this->group = new Group($this->groupID);
25                if (!$this->group->groupID) {
26                        require_once(WCF_DIR.'lib/system/exception/IllegalLinkException.class.php');
27                        throw new IllegalLinkException();
28                }
29                $this->displayNotification = isset($_POST['groupApplyMail_display']) ? intval($_POST['groupApplyMail_display']) : 0;
30                $this->emailNotification = isset($_POST['groupApplyMail_email']) ? intval($_POST['groupApplyMail_email']) : 0;
31               
32        }
33       
34        /**
35         * @see Action::execute()
36         */
37        public function execute() {
38                AbstractAction::execute();
39               
40                // check permission
41                if (!GroupApplicationEditor::isGroupLeader(WCF::getUser()->userID, $this->groupID)) {
42                        require_once(WCF_DIR.'lib/system/exception/PermissionDeniedException.class.php');
43                        throw new PermissionDeniedException();
44                }
45               
46                if($this->displayNotification || $this->emailNotification) {
47                        $sql = "INSERT
48                                INTO            wcf".WCF_N."_group_application_mail
49                                                (userID, groupID, displayNotification, emailNotification)
50                                VALUES
51                                                (".WCF::getUser()->userID.", ".intval($this->groupID).", ".$this->displayNotification.", ".$this->emailNotification.")
52                                ON DUPLICATE KEY
53                                UPDATE          displayNotification=".$this->displayNotification.",
54                                                emailNotification=".$this->emailNotification;
55                       
56                } else {
57                        $sql = "DELETE FROM
58                                                wcf".WCF_N."_group_application_mail
59                                WHERE           userID = ".WCF::getUser()->userID."
60                                AND             groupID = ".intval($this->groupID);
61                }
62               
63                WCF::getDB()->sendQuery($sql);
64                $this->executed();
65               
66                HeaderUtil::redirect('index.php?form=UserGroupAdministrate&groupID='.$this->groupID.SID_ARG_2ND_NOT_ENCODED);
67                exit;
68        }
69}
70?>
Note: See TracBrowser for help on using the browser.