Changeset 298

Show
Ignore:
Timestamp:
03/08/08 20:20:34 (5 years ago)
Author:
d0nut
Message:

application notification table: select, insert, delete

Location:
application.register
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • application.register/files/lib/action/DisableApplicationRegisterNotificationsAction.class.php

    r296 r298  
    55 * UnterdrÃŒckt die Info-Box fÃŒr das Bewerbungshinweis Benutzergruppen - PlugIn durch einen Eintrag in die Datenbank. 
    66 *  
    7  * @author              Markus Gerdelmann 
    8  * @copyright   2007/2008 MDMAN 
    9  * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> 
    10  * @package             de.mdman.application.register 
     7 * @author      Markus Gerdelmann, Torben Brodt 
     8 * @package     de.mdman.application.register 
     9 * @license     GNU General Public License <http://opensource.org/licenses/gpl-3.0.html> 
    1110 */ 
    12  
    1311class DisableApplicationRegisterNotificationsAction extends AbstractAction { 
    1412         
     13        /** 
     14         * @see AbstractAction::execute() 
     15         */ 
    1516        public function execute() { 
    16         parent::execute(); 
     17                parent::execute(); 
    1718                 
    18                 $sql = "SELECT FROM wcf".WCF_N."_group_application applicationID, userID 
    19                                 WHERE userID = ".WCF::getUser()->userID.""; 
    20                 $res = WCF::getDB()->sendQuery($sql); 
    21                 while ($row = WCF::getDB()->fetchArray($res)){ 
    22                         $daten[]=$row; 
    23                 } 
    24                  
    25                 while ($daten){ 
    26                 $sql = "INSERT INTO     wcf".WCF_N."_group_application_notification 
    27                                 SET             userID = ".$daten["userID"].", 
    28                                                         applicationID = ".$daten["applicationID"].", 
    29                                                         disableNotifications = '1'                               
    30                                 "; 
     19                $sql = "DELETE FROM     wcf".WCF_N."_group_application_notification 
     20                        WHERE           userID = ".WCF::getUser()->userID; 
    3121                WCF::getDB()->sendQuery($sql); 
    32                 } 
    3322        } 
    3423} 
  • application.register/files/lib/system/event/listener/ApplicationRegisterListener.class.php

    r296 r298  
    11<?php 
     2// WCF include 
    23require_once(WCF_DIR.'lib/system/event/EventListener.class.php'); 
    34 
     
    56 * Zeigt dem Gruppenleiter einen Hinweis bei Bewerbung eines Users in einer Gruppe 
    67 *  
    7  * @author      Markus Gerdelmann 
     8 * @author      Markus Gerdelmann, Torben Brodt 
    89 * @package     de.mdman.application.register 
     10 * @license     GNU General Public License <http://opensource.org/licenses/gpl-3.0.html> 
    911 */ 
    1012class ApplicationRegisterListener implements EventListener { 
    1113        protected static $check = false; 
     14 
    1215        public $templateName = 'applicationRegister'; 
    1316        public $count = 0; 
     
    1720         */ 
    1821        public function execute($eventObj, $className, $eventName) { 
    19                 if(self::$check) return; 
     22                if(self::$check || WCF::getUser()->userID == 0) return; 
    2023                self::$check = true; 
    2124 
    22                 $sql = "SELECT          usergroup.*, application.*, user.username, application_notification 
    23                                 FROM            wcf".WCF_N."_group_application application 
    24                                 LEFT JOIN       wcf".WCF_N."_group usergroup 
    25                                 ON              (usergroup.groupID = application.groupID) 
    26                                 LEFT JOIN       wcf".WCF_N."_user user 
    27                                 ON              (user.userID = application.userID) 
    28                                 WHERE           application.groupID IN ( 
     25                $sql = "SELECT                  COUNT(*) AS c 
     26                        FROM                    wcf".WCF_N."_group_application_notification 
     27                        NATURAL JOIN            wcf".WCF_N."_group_application application 
     28                        WHERE                   application.groupID IN ( 
    2929                                                        SELECT  groupID 
    3030                                                        FROM    wcf".WCF_N."_group_leader 
    3131                                                        WHERE   userID = ".WCF::getUser()->userID." 
    3232                                                ) 
    33                                 AND             (application_notification.disableNotification != '1' 
    34                                                         AND application_notification.userID = ".WCF::getDB()->userID." 
    35                                                 ) 
    36                                 AND     application.applicationStatus = '0'                              
    37                                 "; 
     33                        AND                     notification.userID = ".WCF::getUser()->userID." 
     34                        AND                     application.applicationStatus = 0"; 
    3835 
    39                 $res = WCF::getDB()->sendQuery($sql);            
    40                 $count = WCF::getDB()->countRows($res); 
     36                $row = WCF::getDB()->getFirstRow($sql); 
    4137 
    42                 if ($count >= 1){ 
    43                 //Hier werden die Variablen im Template registriert 
     38                if (intval($row['c']) > 0){ 
     39                        //Hier werden die Variablen im Template registriert 
    4440                        WCF::getTPL()->assign(array( 
    45                  'count' => $count, 
    46             )); 
    47         //Hier wird das Template in dem Platzhalter userMessages integriert. 
     41                                'count' => $row['c'] 
     42                        )); 
     43 
     44                        //Hier wird das Template in dem Platzhalter userMessages integriert. 
    4845                        WCF::getTPL()->append('userMessages', WCF::getTPL()->fetch('applicationRegister')); 
    4946                } 
    50          
    5147        } 
    52          
    5348} 
    5449?> 
  • application.register/files/lib/system/event/listener/UserGroupAdministrateMailListener.class.php

    r292 r298  
    66 * more options to groupleaders 
    77 * 
    8  * @author      Torben Brodt 
    9  * @package     de.easy-coding.wcf.groupapplymail 
     8 * @author      Markus Gerdelmann, Torben Brodt 
     9 * @package     de.mdman.application.register 
    1010 * @license     GNU General Public License <http://opensource.org/licenses/gpl-3.0.html> 
    1111 */ 
  • application.register/files/lib/system/event/listener/UserGroupApplyMailListener.class.php

    r292 r298  
    44 
    55/** 
    6  * sends emails to group leaders 
     6 * sends emails to group leaders and places a display notification 
    77 * 
    8  * @author      Torben Brodt 
    9  * @package     de.easy-coding.wcf.groupapplymail 
     8 * @author      Markus Gerdelmann, Torben Brodt 
     9 * @package     de.mdman.application.register 
    1010 * @license     GNU General Public License <http://opensource.org/licenses/gpl-3.0.html> 
    1111 */ 
    1212class UserGroupApplyMailListener implements EventListener { 
     13        protected $this->eventObj; 
    1314 
    1415        /** 
     
    1617         */ 
    1718        public function execute($eventObj, $className, $eventName) { 
     19                $this->eventObj = $eventObj; 
     20 
     21                // requires 
    1822                require_once(WCF_DIR.'lib/data/mail/Mail.class.php'); 
    1923                require_once(WCF_DIR.'lib/system/language/Language.class.php'); 
    2024                 
    2125                // send notifications 
    22                 $languages = array(); 
    23                 $languages[WCF::getLanguage()->getLanguageID()] = WCF::getLanguage(); 
    24                 $languages[0] = WCF::getLanguage(); 
    25                 $sql = "SELECT          user.* 
    26                         FROM            wcf".WCF_N."_groupapplymail 
     26                $sql = "SELECT          user.*, 
     27                                        displayNotification, 
     28                                        emailNotification 
     29                        FROM            wcf".WCF_N."_group_application_mail 
    2730                        NATURAL JOIN    wcf".WCF_N."_user user 
    28                         WHERE           groupID = ".intval($eventObj->group->groupID)." 
     31                        WHERE           groupID = ".intval($this->eventObj->group->groupID)." 
    2932                        AND             emailNotification = 1"; 
    3033                $result = WCF::getDB()->sendQuery($sql); 
    3134                while ($row = WCF::getDB()->fetchArray($result)) { 
    3235                        if ($row['userID'] == WCF::getUser()->userID) { 
    33                                 //continue; 
     36                                continue; 
    3437                        } 
    3538                         
    36                         // get language 
    37                         if (!isset($languages[$row['languageID']])) { 
    38                                 $languages[$row['languageID']] = new Language($row['languageID']);       
     39                        if($row['displayNotification']) { 
     40                                $this->display($row); 
    3941                        } 
    40                  
    41                         // enable language 
    42                         $languages[$row['languageID']]->setLocale(); 
    43  
    44                         // send mail 
    45                         $subjectData = array( 
    46                                 '$author' => WCF::getUser()->username, 
    47                                 '$group' => $eventObj->group, 
    48                                 'PAGE_TITLE' => PAGE_TITLE 
    49                         ); 
    50                         $messageData = array( 
    51                                 '$author' => WCF::getUser()->username, 
    52                                 '$group' => $eventObj->group, 
    53                                 'PAGE_TITLE' => PAGE_TITLE, 
    54                                 '$pageurl' => FileUtil::addTrailingSlash(PAGE_URL), 
    55                                 '$recipient' => $row['username'], 
    56                                 '$reason' => isset($eventObj->reason) ? $eventObj->reason : '' 
    57                         ); 
    58  
    59                         $mail = new Mail(array($row['username'] => $row['email']), $languages[$row['languageID']]->get('wcf.groupapplymail.mail.subject.'.$eventObj->group->groupType, $subjectData), $languages[$row['languageID']]->get('wcf.groupapplymail.mail.body.'.$eventObj->group->groupType, $messageData)); 
    60                         $mail->send(); 
     42                        if($row['emailNotification']) { 
     43                                $this->email($row); 
     44                        } 
    6145                } 
    6246                 
     
    6448                WCF::getLanguage()->setLocale(); 
    6549        } 
     50         
     51        /** 
     52         * 
     53         */ 
     54        protected function display($row) { 
     55                $sql = "INSERT INTO     wcf".WCF_N."_group_application_notification 
     56                                        (applicationID, userID) 
     57                        VALUES          (".$this->eventObj->applicationID.", ".$row['userID'].")"; 
     58                WCF::getDB()->sendQuery($sql); 
     59        } 
     60         
     61        /** 
     62         * 
     63         */ 
     64        protected function email($row) { 
     65                $languages = array(); 
     66                $languages[WCF::getLanguage()->getLanguageID()] = WCF::getLanguage(); 
     67                $languages[0] = WCF::getLanguage(); 
     68 
     69                // get language 
     70                if (!isset($languages[$row['languageID']])) { 
     71                        $languages[$row['languageID']] = new Language($row['languageID']);       
     72                } 
     73         
     74                // enable language 
     75                $languages[$row['languageID']]->setLocale(); 
     76 
     77                // send mail 
     78                $subjectData = array( 
     79                        '$author' => WCF::getUser()->username, 
     80                        '$group' => $this->eventObj->group, 
     81                        'PAGE_TITLE' => PAGE_TITLE 
     82                ); 
     83                $messageData = array( 
     84                        '$author' => WCF::getUser()->username, 
     85                        '$group' => $this->eventObj->group, 
     86                        'PAGE_TITLE' => PAGE_TITLE, 
     87                        '$pageurl' => FileUtil::addTrailingSlash(PAGE_URL), 
     88                        '$recipient' => $row['username'], 
     89                        '$reason' => isset($this->eventObj->reason) ? $this->eventObj->reason : '' 
     90                ); 
     91 
     92                $mail = new Mail(array($row['username'] => $row['email']), $languages[$row['languageID']]->get('wcf.groupapplymail.mail.subject.'.$this->eventObj->group->groupType, $subjectData), $languages[$row['languageID']]->get('wcf.groupapplymail.mail.body.'.$this->eventObj->group->groupType, $messageData)); 
     93                $mail->send(); 
     94        } 
    6695} 
    6796?> 
  • application.register/install.sql

    r295 r298  
    1  
    2  
     1DROP TABLE IF EXISTS wcf1_group_application_mail; 
    32CREATE TABLE IF NOT EXISTS wcf1_group_application_mail ( 
    43  userID int(10) unsigned NOT NULL, 
     
    98) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    109 
     10DROP TABLE IF EXISTS wcf1_group_application_notification; 
    1111CREATE TABLE IF NOT EXISTS wcf1_group_application_notification ( 
    1212  applicationID int(11) unsigned NOT NULL, 
    1313  userID int(10) unsigned NOT NULL, 
    14   disableNotification TINYINT(1) unsigned NOT NULL, 
    1514  PRIMARY KEY (applicationID,userID) 
    1615) ENGINE=MyISAM DEFAULT CHARSET=utf8;