Changeset 321

Show
Ignore:
Timestamp:
03/12/08 22:08:11 (5 years ago)
Author:
d0nut
Message:

untested caching system

Location:
groupapplymail
Files:
7 added
10 modified

Legend:

Unmodified
Added
Removed
  • groupapplymail/de-informal.xml

    r269 r321  
    33<language languagecode="de-informal"> 
    44        <category name="wcf.groupapplymail"> 
     5                <item name="wcf.groupapplymail.application.register.info"><![CDATA[{if $count == 1}Du hast noch eine unbearbeitete Bewerbung fÃŒr eine Benutzergruppe.<br/><a href="index.php?page=UserGroupLeader{@SID_ARG_2ND}">Direkt zur Bewerbung...</a>{/if}{if $count > 1}Du hast noch unbearbeitete Bewerbungen fÃŒr Benutzergruppen.<br/><a href="index.php?page=UserGroupLeader{@SID_ARG_2ND}">Direkt zu den Bewerbungen...</a>{/if}]]></item> 
     6 
    57                <item name="wcf.groupapplymail.options"><![CDATA[Gruppen-Optionen]]></item> 
    68                <item name="wcf.groupapplymail.mail.subject.5"><![CDATA[{$author} ist der Gruppe {$group->groupname} beigetreten]]></item> 
     
    3537                <item name="wcf.groupapplymail.enableEmailNotification.6"><![CDATA[E-Mail-Benachrichtigung bei Bewerbungen]]></item> 
    3638                <item name="wcf.groupapplymail.enableEmailNotification.6.description"><![CDATA[]]></item> 
     39                <item name="wcf.groupapplymail.enableDisplayNotification.5"><![CDATA[Hinweisbox bei Neuaufnahmen]]></item> 
     40                <item name="wcf.groupapplymail.enableDisplayNotification.5.description"><![CDATA[]]></item> 
     41                <item name="wcf.groupapplymail.enableDisplayNotification.6"><![CDATA[Hinweisbox bei Bewerbungen]]></item> 
     42                <item name="wcf.groupapplymail.enableDisplayNotification.6.description"><![CDATA[]]></item> 
    3743        </category> 
    3844</language> 
  • groupapplymail/de.xml

    r269 r321  
    33<language languagecode="de"> 
    44        <category name="wcf.groupapplymail"> 
     5                <item name="wcf.groupapplymail.application.register.info"><![CDATA[]]></item> 
     6 
    57                <item name="wcf.groupapplymail.options"><![CDATA[Gruppen-Optionen]]></item> 
    68                <item name="wcf.groupapplymail.mail.subject.5"><![CDATA[{$author} ist der Gruppe {$group->groupname} beigetreten]]></item> 
     
    3537                <item name="wcf.groupapplymail.enableEmailNotification.6"><![CDATA[E-Mail-Benachrichtigung bei Bewerbungen]]></item> 
    3638                <item name="wcf.groupapplymail.enableEmailNotification.6.description"><![CDATA[]]></item> 
     39                <item name="wcf.groupapplymail.enableDisplayNotification.5"><![CDATA[Hinweisbox bei Neuaufnahmen]]></item> 
     40                <item name="wcf.groupapplymail.enableDisplayNotification.5.description"><![CDATA[]]></item> 
     41                <item name="wcf.groupapplymail.enableDisplayNotification.6"><![CDATA[Hinweisbox bei Bewerbungen]]></item> 
     42                <item name="wcf.groupapplymail.enableDisplayNotification.6.description"><![CDATA[]]></item> 
    3743        </category> 
    3844</language> 
  • groupapplymail/en.xml

    r269 r321  
    33<language languagecode="en"> 
    44        <category name="wcf.groupapplymail"> 
    5                 <item name="wcf.groupapplymail.options"><![CDATA[Gruppen-Optionen]]></item> 
     5                <item name="wcf.groupapplymail.application.register.info"><![CDATA[{if $count == 1}Es ist eine unbearbeitete Bewerbung fÃŒr eine Benutzergruppe vorhanden.<br/><a href="index.php?page=UserGroupLeader{@SID_ARG_2ND}">Direkt zur Bewerbung...</a>{/if}{if $count > 1}Es sind noch unbearbeitete Bewerbungen fÃŒr Benutzergruppen vorhanden.<br/><a href="index.php?page=UserGroupLeader{@SID_ARG_2ND}">Direkt zu den Bewerbungen...</a>{/if}]]></item> 
     6 
     7                <item name="wcf.groupapplymail.options"><![CDATA[Group-Options]]></item> 
    68                <item name="wcf.groupapplymail.mail.subject.5"><![CDATA[{$author} joined the group: {$group->groupname}]]></item> 
    79                <item name="wcf.groupapplymail.mail.subject.6"><![CDATA[{$author} wants to join the group: {$group->groupname}]]></item> 
     
    3537                <item name="wcf.groupapplymail.enableEmailNotification.6"><![CDATA[E-Mail-Notification after application]]></item> 
    3638                <item name="wcf.groupapplymail.enableEmailNotification.6.description"><![CDATA[]]></item> 
     39                <item name="wcf.groupapplymail.enableDisplayNotification.5"><![CDATA[Infobox after join]]></item> 
     40                <item name="wcf.groupapplymail.enableDisplayNotification.5.description"><![CDATA[]]></item> 
     41                <item name="wcf.groupapplymail.enableDisplayNotification.6"><![CDATA[Infobox after application]]></item> 
     42                <item name="wcf.groupapplymail.enableDisplayNotification.6.description"><![CDATA[]]></item> 
    3743        </category> 
    3844</language> 
  • groupapplymail/eventlistener.xml

    r269 r321  
    11<?xml version="1.0"?> 
    22<!DOCTYPE data SYSTEM "http://www.woltlab.com/DTDs/eventListeners.dtd"> 
    3 <data>   
     3<data> 
    44        <import> 
    5                 <eventlistener> 
     5                <eventlistener><!-- leader accepts/deletes/rereads/... application //--> 
     6                        <eventclassname>UserGroupLeaderApplicationEditForm</eventclassname> 
     7                        <eventname>saved</eventname> 
     8                        <listenerclassfile>lib/system/event/listener/UserGroupLeaderApplicationEditMailListener.class.php</listenerclassfile> 
     9                </eventlistener> 
     10                <eventlistener><!-- leader deletes application //--> 
     11                        <eventclassname>UserGroupApplicationDeleteAction</eventclassname> 
     12                        <eventname>execute</eventname> 
     13                        <listenerclassfile>lib/system/event/listener/UserGroupApplicationDeleteMailListener.class.php</listenerclassfile> 
     14                </eventlistener> 
     15 
     16                <eventlistener><!-- user regrets application //--> 
     17                        <eventclassname>UserGroupApplicationEditForm</eventclassname> 
     18                        <eventname>saved</eventname> 
     19                        <listenerclassfile>lib/system/event/listener/UserGroupApplicationEditMailListener.class.php</listenerclassfile> 
     20                </eventlistener> 
     21 
     22                <eventlistener><!-- show infobox //--> 
     23                        <eventClassName>AbstractPage</eventClassName> 
     24                        <eventName>assignVariables</eventName> 
     25                        <listenerClassFile>lib/system/event/listener/AbstractPageGroupActivityListener.class.php</listenerClassFile> 
     26                        <inherit>1</inherit> 
     27                </eventlistener> 
     28                 
     29                <eventlistener><!-- add new application //--> 
    630                        <eventclassname>UserGroupApplyForm</eventclassname> 
    731                        <eventname>saved</eventname> 
    832                        <listenerclassfile>lib/system/event/listener/UserGroupApplyMailListener.class.php</listenerclassfile> 
    933                </eventlistener> 
    10                 <eventlistener> 
     34                <eventlistener><!-- join the group //--> 
    1135                        <eventclassname>UserGroupJoinAction</eventclassname> 
    1236                        <eventname>executed</eventname> 
    1337                        <listenerclassfile>lib/system/event/listener/UserGroupApplyMailListener.class.php</listenerclassfile> 
    1438                </eventlistener> 
    15                 <eventlistener> 
     39                <eventlistener><!-- Group <-> User options //--> 
    1640                        <eventclassname>UserGroupAdministrateForm</eventclassname> 
    1741                        <eventname>readData</eventname> 
    1842                        <listenerclassfile>lib/system/event/listener/UserGroupAdministrateMailListener.class.php</listenerclassfile> 
    1943                </eventlistener> 
    20                 <eventlistener> 
     44                <eventlistener><!-- Group <-> User options //--> 
    2145                        <eventclassname>UserGroupAdministrateForm</eventclassname> 
    2246                        <eventname>assignVariables</eventname> 
  • groupapplymail/files/lib/action/UserGroupOptionsAction.class.php

    r269 r321  
    1111 */ 
    1212class UserGroupOptionsAction extends AbstractAction { 
    13         public $enabled = array(); 
     13        public $displayNotification=0, $emailNotification=0; 
    1414        public $groupID = 0; 
    1515        public $group; 
     
    2727                        throw new IllegalLinkException(); 
    2828                } 
     29                $this->displayNotification = isset($_POST['groupApplyMail_display']) ? intval($_POST['groupApplyMail_display']) : 0; 
     30                $this->emailNotification = isset($_POST['groupApplyMail_email']) ? intval($_POST['groupApplyMail_email']) : 0; 
    2931                 
    30                 $this->enabled = isset($_POST['groupApplyMail_enabled']) ? intval($_POST['groupApplyMail_enabled']) : 0; 
    3132        } 
    3233         
     
    4344                } 
    4445                 
    45                 if($this->enabled) { 
    46                         $sql = "INSERT IGNORE  
    47                                 INTO            wcf".WCF_N."_groupapplymail 
    48                                                 (userID, groupID) 
     46                if($this->displayNotification || $this->emailNotification) { 
     47                        $sql = "INSERT 
     48                                INTO            wcf".WCF_N."_group_user_option 
     49                                                (userID, groupID, displayNotification, emailNotification) 
    4950                                VALUES 
    50                                                 (".WCF::getUser()->userID.", ".intval($this->groupID).")"; 
     51                                                (".WCF::getUser()->userID.", ".intval($this->groupID).", ".$this->displayNotification.", ".$this->emailNotification.") 
     52                                ON DUPLICATE KEY 
     53                                UPDATE          displayNotification=".$this->displayNotification.", 
     54                                                emailNotification=".$this->emailNotification; 
    5155                         
    5256                } else { 
    5357                        $sql = "DELETE FROM  
    54                                                 wcf".WCF_N."_groupapplymail 
     58                                                wcf".WCF_N."_group_user_option 
    5559                                WHERE           userID = ".WCF::getUser()->userID." 
    5660                                AND             groupID = ".intval($this->groupID); 
  • groupapplymail/files/lib/system/event/listener/UserGroupAdministrateMailListener.class.php

    r269 r321  
    1515         
    1616        //data 
    17         protected $enabled; 
     17        protected $displayNotification=0, $emailNotification=0; 
    1818 
    1919        /** 
     
    3838         */ 
    3939        protected function readData() { 
    40                 $sql = "SELECT          COUNT(*) AS c 
    41                         FROM            wcf".WCF_N."_groupapplymail 
     40                $sql = "SELECT          displayNotification, 
     41                                        emailNotification 
     42                        FROM            wcf".WCF_N."_group_user_option 
    4243                        WHERE           groupID = ".intval($this->eventObj->groupID)." 
    4344                        AND             userID = ".WCF::getUser()->userID; 
    4445                $row = WCF::getDB()->getFirstRow($sql); 
    45                 $this->enabled = intval($row['c']); 
     46                if($row) { 
     47                        $this->displayNotification = intval($row['displayNotification']); 
     48                        $this->emailNotification = intval($row['emailNotification']); 
     49                } 
    4650        } 
    4751 
     
    5256                WCF::getTPL()->assign(array( 
    5357                        'groupID' => $this->eventObj->groupID, 
    54                         'enabled' => $this->enabled, 
     58                        'display' => $this->displayNotification, 
     59                        'email' => $this->emailNotification, 
    5560                        'groupType' => $this->eventObj->group->groupType 
    5661                )); 
  • groupapplymail/files/lib/system/event/listener/UserGroupApplyMailListener.class.php

    r269 r321  
    44 
    55/** 
    6  * sends emails to group leaders 
     6 * sends emails to group leaders and places a display notification 
    77 * 
    88 * @author      Torben Brodt 
     
    1111 */ 
    1212class UserGroupApplyMailListener implements EventListener { 
     13        protected $eventObj; 
    1314 
    1415        /** 
     
    1617         */ 
    1718        public function execute($eventObj, $className, $eventName) { 
    18                 require_once(WCF_DIR.'lib/data/mail/Mail.class.php'); 
    19                 require_once(WCF_DIR.'lib/system/language/Language.class.php'); 
    20                  
     19                $this->eventObj = $eventObj; 
     20                $i=0; 
     21 
    2122                // 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 
     23                $sql = "SELECT          user.*, 
     24                                        displayNotification, 
     25                                        emailNotification 
     26                        FROM            wcf".WCF_N."_group_user_option 
    2727                        NATURAL JOIN    wcf".WCF_N."_user user 
    28                         WHERE           groupID = ".intval($eventObj->group->groupID); 
     28                        WHERE           groupID = ".$this->eventObj->group->groupID." 
     29                        AND             emailNotification = 1"; 
    2930                $result = WCF::getDB()->sendQuery($sql); 
    3031                while ($row = WCF::getDB()->fetchArray($result)) { 
    31                         if ($row['userID'] == WCF::getUser()->userID) { 
    32                                 //continue; 
     32                        if($row['userID'] == WCF::getUser()->userID) { 
     33                                continue; 
    3334                        } 
    3435                         
    35                         // get language 
    36                         if (!isset($languages[$row['languageID']])) { 
    37                                 $languages[$row['languageID']] = new Language($row['languageID']);       
     36                        if($row['displayNotification']) { 
     37                                $this->display($row); 
     38                                $i++; 
    3839                        } 
     40                        if($row['emailNotification']) { 
     41                                $this->email($row); 
     42                        } 
     43                } 
    3944                 
    40                         // enable language 
    41                         $languages[$row['languageID']]->setLocale(); 
    42  
    43                         // send mail 
    44                         $subjectData = array( 
    45                                 '$author' => WCF::getUser()->username, 
    46                                 '$group' => $eventObj->group, 
    47                                 'PAGE_TITLE' => PAGE_TITLE 
    48                         ); 
    49                         $messageData = array( 
    50                                 '$author' => WCF::getUser()->username, 
    51                                 '$group' => $eventObj->group, 
    52                                 'PAGE_TITLE' => PAGE_TITLE, 
    53                                 '$pageurl' => FileUtil::addTrailingSlash(PAGE_URL), 
    54                                 '$recipient' => $row['username'], 
    55                                 '$reason' => isset($eventObj->reason) ? $eventObj->reason : '' 
    56                         ); 
    57  
    58                         $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)); 
    59                         $mail->send(); 
     45                if($i > 0) { 
     46                        // update cache 
     47                        WCF::getCache()->addResource('groupapplymail',  
     48                                WCF_DIR.'cache/cache.groupapplymail.php', 
     49                                WCF_DIR.'lib/system/cache/CacheBuilderGroupApplyMail.class.php'); 
    6050                } 
    6151                 
     
    6353                WCF::getLanguage()->setLocale(); 
    6454        } 
     55         
     56        /** 
     57         * adds a display notification 
     58         * @param row           array           all required data 
     59         */ 
     60        protected function display($row) { 
     61                $applicationID = $this->eventObj->group->groupID == 6 ? $this->eventObj->applicationID : "0"; 
     62         
     63                $sql = "INSERT INTO     wcf".WCF_N."_group_user_notification 
     64                                        (userID, groupID, foreignID, messageType, slot1) 
     65                        VALUES          ( 
     66                                                ".$row['userID'].",  
     67                                                ".$this->eventObj->group->groupID.",  
     68                                                ".$applicationID.",  
     69                                                ".$this->eventObj->group->groupType.",  
     70                                                '".WCF::getUser()->username."')"; 
     71                WCF::getDB()->sendQuery($sql); 
     72        } 
     73         
     74        /** 
     75         * sends email 
     76         * @param row           array           all required data 
     77         * @return              boolean         mail success 
     78         */ 
     79        protected function email($row) { 
     80                // requires 
     81                require_once(WCF_DIR.'lib/data/mail/Mail.class.php'); 
     82                require_once(WCF_DIR.'lib/system/language/Language.class.php'); 
     83 
     84                $languages = array(); 
     85                $languages[WCF::getLanguage()->getLanguageID()] = WCF::getLanguage(); 
     86                $languages[0] = WCF::getLanguage(); 
     87 
     88                // get language 
     89                if (!isset($languages[$row['languageID']])) { 
     90                        $languages[$row['languageID']] = new Language($row['languageID']);       
     91                } 
     92         
     93                // enable language 
     94                $languages[$row['languageID']]->setLocale(); 
     95 
     96                // send mail 
     97                $subjectData = array( 
     98                        '$author' => WCF::getUser()->username, 
     99                        '$group' => $this->eventObj->group, 
     100                        'PAGE_TITLE' => PAGE_TITLE 
     101                ); 
     102                $messageData = array( 
     103                        '$author' => WCF::getUser()->username, 
     104                        '$group' => $this->eventObj->group, 
     105                        'PAGE_TITLE' => PAGE_TITLE, 
     106                        '$pageurl' => FileUtil::addTrailingSlash(PAGE_URL), 
     107                        '$recipient' => $row['username'], 
     108                        '$reason' => isset($this->eventObj->reason) ? $this->eventObj->reason : '' 
     109                ); 
     110 
     111                $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)); 
     112                return $mail->send(); 
     113        } 
    65114} 
    66115?> 
  • groupapplymail/install.sql

    r288 r321  
    1 CREATE TABLE IF NOT EXISTS wcf1_groupapplymail ( 
     1DROP TABLE IF EXISTS wcf1_group_user_option; 
     2CREATE TABLE wcf1_group_user_option ( 
    23  userID int(10) unsigned NOT NULL, 
    34  groupID int(10) unsigned NOT NULL, 
    4   UNIQUE KEY userID (userID,groupID) 
     5  displayNotification tinyint(1) unsigned NOT NULL DEFAULT 0, 
     6  emailNotification tinyint(1) unsigned NOT NULL DEFAULT 0, 
     7  PRIMARY KEY (userID,groupID) 
    58) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
     9 
     10DROP TABLE IF EXISTS wcf1_group_user_notification; 
     11CREATE TABLE wcf1_group_user_notification ( 
     12  userID int(10) unsigned NOT NULL, 
     13  groupID int(10) unsigned NOT NULL, 
     14  foreignID int(10) unsigned NOT NULL, 
     15  messageType tinyint(3) unsigned NOT NULL, 
     16  slot1 varchar(255), --username 
     17  slot2 varchar(255), --groupleader 
     18  slot3 varchar(255), 
     19  slot4 varchar(255), 
     20  slot5 varchar(255), 
     21  PRIMARY KEY (userID, groupID, foreignID) 
     22) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
     23 
     24-- messageType  
     25--              5 = join 
     26--              51 = {$groupleader} wird die Bearbeitung des Benutzers {$username} ÃŒbernehmen 
     27--              52 = {$groupleader} hat {$username} abgelehnt 
     28--              53 = {$groupleader} hat {$username} akzeptiert 
     29--              6 = application 
     30--              7 = zurÃŒcknehmen 
  • groupapplymail/package.xml

    r276 r321  
    2424        <instructions type="install"> 
    2525                <files>files.tar</files> 
    26                 <templates>templates.tar</templates> 
    27                 <sql>install.sql</sql> 
    28                 <eventlistener>eventlistener.xml</eventlistener> 
    2926                <languages languagecode="de">de.xml</languages> 
    3027                <languages languagecode="de-informal">de-informal.xml</languages> 
    3128                <languages languagecode="en">en.xml</languages> 
     29                <templates>templates.tar</templates> 
     30                <eventlistener>eventlistener.xml</eventlistener> 
    3231                <templatepatch>templates.diff</templatepatch> 
     32                <sql>install.sql</sql> 
    3333        </instructions> 
    3434</package> 
  • groupapplymail/templates/userGroupApplyMail.tpl

    r269 r321  
    33                <legend>{lang}wcf.groupapplymail.options{/lang}</legend> 
    44 
    5                 <div class="formCheckBox formElement" id="enableGroupApplyMailDiv"> 
     5                <div class="formCheckBox formElement"> 
     6                        <div class="formField"> 
     7                                <label for="enableGroupApplyMailDisplay"><input id="enableGroupApplyMailDisplay" type="checkbox" name="groupApplyMail_display" value="1" 
     8                                {if $display}checked="checked"{/if}/> {lang}wcf.groupapplymail.enableDisplayNotification.{$groupType}{/lang}</label> 
     9                        </div> 
    610 
     11                        <div class="formFieldDesc"> 
     12                                <p>{lang}wcf.groupapplymail.enableDisplayNotification.{$groupType}.description{/lang}</p> 
     13                        </div> 
     14                </div> 
     15                 
     16                <div class="formCheckBox formElement"> 
    717                        <div class="formField"> 
    8                                 <label for="enableGroupApplyMail"><input id="enableGroupApplyMail" type="checkbox" name="groupApplyMail_enabled" value="1" 
    9                                 {if $enabled}checked="checked"{/if}/> {lang}wcf.groupapplymail.enableEmailNotification.{$groupType}{/lang}</label> 
     18                                <label for="enableGroupApplyMailEmail"><input id="enableGroupApplyMailEmail" type="checkbox" name="groupApplyMail_email" value="1" 
     19                                {if $email}checked="checked"{/if}/> {lang}wcf.groupapplymail.enableEmailNotification.{$groupType}{/lang}</label> 
    1020                        </div> 
    1121