Changeset 321
- Timestamp:
- 03/12/08 22:08:11 (5 years ago)
- Location:
- groupapplymail
- Files:
-
- 7 added
- 10 modified
-
de-informal.xml (modified) (2 diffs)
-
de.xml (modified) (2 diffs)
-
en.xml (modified) (2 diffs)
-
eventlistener.xml (modified) (1 diff)
-
files/lib/action/DisableGroupActivitiyNotificationsAction.class.php (added)
-
files/lib/action/UserGroupOptionsAction.class.php (modified) (3 diffs)
-
files/lib/system/cache (added)
-
files/lib/system/cache/CacheBuilderGroupApplyMail.class.php (added)
-
files/lib/system/event/listener/AbstractPageGroupActivityListener.class.php (added)
-
files/lib/system/event/listener/UserGroupAdministrateMailListener.class.php (modified) (3 diffs)
-
files/lib/system/event/listener/UserGroupApplicationDeleteMailListener.class.php (added)
-
files/lib/system/event/listener/UserGroupApplyMailListener.class.php (modified) (4 diffs)
-
files/lib/system/event/listener/UserGroupLeaderApplicationEditMailListener.class.php (added)
-
install.sql (modified) (1 diff)
-
package.xml (modified) (1 diff)
-
templates/userGroupActivities.tpl (added)
-
templates/userGroupApplyMail.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
groupapplymail/de-informal.xml
r269 r321 3 3 <language languagecode="de-informal"> 4 4 <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 5 7 <item name="wcf.groupapplymail.options"><![CDATA[Gruppen-Optionen]]></item> 6 8 <item name="wcf.groupapplymail.mail.subject.5"><![CDATA[{$author} ist der Gruppe {$group->groupname} beigetreten]]></item> … … 35 37 <item name="wcf.groupapplymail.enableEmailNotification.6"><![CDATA[E-Mail-Benachrichtigung bei Bewerbungen]]></item> 36 38 <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> 37 43 </category> 38 44 </language> -
groupapplymail/de.xml
r269 r321 3 3 <language languagecode="de"> 4 4 <category name="wcf.groupapplymail"> 5 <item name="wcf.groupapplymail.application.register.info"><![CDATA[]]></item> 6 5 7 <item name="wcf.groupapplymail.options"><![CDATA[Gruppen-Optionen]]></item> 6 8 <item name="wcf.groupapplymail.mail.subject.5"><![CDATA[{$author} ist der Gruppe {$group->groupname} beigetreten]]></item> … … 35 37 <item name="wcf.groupapplymail.enableEmailNotification.6"><![CDATA[E-Mail-Benachrichtigung bei Bewerbungen]]></item> 36 38 <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> 37 43 </category> 38 44 </language> -
groupapplymail/en.xml
r269 r321 3 3 <language languagecode="en"> 4 4 <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> 6 8 <item name="wcf.groupapplymail.mail.subject.5"><![CDATA[{$author} joined the group: {$group->groupname}]]></item> 7 9 <item name="wcf.groupapplymail.mail.subject.6"><![CDATA[{$author} wants to join the group: {$group->groupname}]]></item> … … 35 37 <item name="wcf.groupapplymail.enableEmailNotification.6"><![CDATA[E-Mail-Notification after application]]></item> 36 38 <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> 37 43 </category> 38 44 </language> -
groupapplymail/eventlistener.xml
r269 r321 1 1 <?xml version="1.0"?> 2 2 <!DOCTYPE data SYSTEM "http://www.woltlab.com/DTDs/eventListeners.dtd"> 3 <data> 3 <data> 4 4 <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 //--> 6 30 <eventclassname>UserGroupApplyForm</eventclassname> 7 31 <eventname>saved</eventname> 8 32 <listenerclassfile>lib/system/event/listener/UserGroupApplyMailListener.class.php</listenerclassfile> 9 33 </eventlistener> 10 <eventlistener> 34 <eventlistener><!-- join the group //--> 11 35 <eventclassname>UserGroupJoinAction</eventclassname> 12 36 <eventname>executed</eventname> 13 37 <listenerclassfile>lib/system/event/listener/UserGroupApplyMailListener.class.php</listenerclassfile> 14 38 </eventlistener> 15 <eventlistener> 39 <eventlistener><!-- Group <-> User options //--> 16 40 <eventclassname>UserGroupAdministrateForm</eventclassname> 17 41 <eventname>readData</eventname> 18 42 <listenerclassfile>lib/system/event/listener/UserGroupAdministrateMailListener.class.php</listenerclassfile> 19 43 </eventlistener> 20 <eventlistener> 44 <eventlistener><!-- Group <-> User options //--> 21 45 <eventclassname>UserGroupAdministrateForm</eventclassname> 22 46 <eventname>assignVariables</eventname> -
groupapplymail/files/lib/action/UserGroupOptionsAction.class.php
r269 r321 11 11 */ 12 12 class UserGroupOptionsAction extends AbstractAction { 13 public $ enabled = array();13 public $displayNotification=0, $emailNotification=0; 14 14 public $groupID = 0; 15 15 public $group; … … 27 27 throw new IllegalLinkException(); 28 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; 29 31 30 $this->enabled = isset($_POST['groupApplyMail_enabled']) ? intval($_POST['groupApplyMail_enabled']) : 0;31 32 } 32 33 … … 43 44 } 44 45 45 if($this-> enabled) {46 $sql = "INSERT IGNORE47 INTO wcf".WCF_N."_group applymail48 (userID, groupID )46 if($this->displayNotification || $this->emailNotification) { 47 $sql = "INSERT 48 INTO wcf".WCF_N."_group_user_option 49 (userID, groupID, displayNotification, emailNotification) 49 50 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; 51 55 52 56 } else { 53 57 $sql = "DELETE FROM 54 wcf".WCF_N."_group applymail58 wcf".WCF_N."_group_user_option 55 59 WHERE userID = ".WCF::getUser()->userID." 56 60 AND groupID = ".intval($this->groupID); -
groupapplymail/files/lib/system/event/listener/UserGroupAdministrateMailListener.class.php
r269 r321 15 15 16 16 //data 17 protected $ enabled;17 protected $displayNotification=0, $emailNotification=0; 18 18 19 19 /** … … 38 38 */ 39 39 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 42 43 WHERE groupID = ".intval($this->eventObj->groupID)." 43 44 AND userID = ".WCF::getUser()->userID; 44 45 $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 } 46 50 } 47 51 … … 52 56 WCF::getTPL()->assign(array( 53 57 'groupID' => $this->eventObj->groupID, 54 'enabled' => $this->enabled, 58 'display' => $this->displayNotification, 59 'email' => $this->emailNotification, 55 60 'groupType' => $this->eventObj->group->groupType 56 61 )); -
groupapplymail/files/lib/system/event/listener/UserGroupApplyMailListener.class.php
r269 r321 4 4 5 5 /** 6 * sends emails to group leaders 6 * sends emails to group leaders and places a display notification 7 7 * 8 8 * @author Torben Brodt … … 11 11 */ 12 12 class UserGroupApplyMailListener implements EventListener { 13 protected $eventObj; 13 14 14 15 /** … … 16 17 */ 17 18 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 21 22 // 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 27 27 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"; 29 30 $result = WCF::getDB()->sendQuery($sql); 30 31 while ($row = WCF::getDB()->fetchArray($result)) { 31 if ($row['userID'] == WCF::getUser()->userID) {32 //continue;32 if($row['userID'] == WCF::getUser()->userID) { 33 continue; 33 34 } 34 35 35 // get language36 if (!isset($languages[$row['languageID']])) {37 $ languages[$row['languageID']] = new Language($row['languageID']);36 if($row['displayNotification']) { 37 $this->display($row); 38 $i++; 38 39 } 40 if($row['emailNotification']) { 41 $this->email($row); 42 } 43 } 39 44 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'); 60 50 } 61 51 … … 63 53 WCF::getLanguage()->setLocale(); 64 54 } 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 } 65 114 } 66 115 ?> -
groupapplymail/install.sql
r288 r321 1 CREATE TABLE IF NOT EXISTS wcf1_groupapplymail ( 1 DROP TABLE IF EXISTS wcf1_group_user_option; 2 CREATE TABLE wcf1_group_user_option ( 2 3 userID int(10) unsigned NOT NULL, 3 4 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) 5 8 ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 9 10 DROP TABLE IF EXISTS wcf1_group_user_notification; 11 CREATE 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 24 24 <instructions type="install"> 25 25 <files>files.tar</files> 26 <templates>templates.tar</templates>27 <sql>install.sql</sql>28 <eventlistener>eventlistener.xml</eventlistener>29 26 <languages languagecode="de">de.xml</languages> 30 27 <languages languagecode="de-informal">de-informal.xml</languages> 31 28 <languages languagecode="en">en.xml</languages> 29 <templates>templates.tar</templates> 30 <eventlistener>eventlistener.xml</eventlistener> 32 31 <templatepatch>templates.diff</templatepatch> 32 <sql>install.sql</sql> 33 33 </instructions> 34 34 </package> -
groupapplymail/templates/userGroupApplyMail.tpl
r269 r321 3 3 <legend>{lang}wcf.groupapplymail.options{/lang}</legend> 4 4 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> 6 10 11 <div class="formFieldDesc"> 12 <p>{lang}wcf.groupapplymail.enableDisplayNotification.{$groupType}.description{/lang}</p> 13 </div> 14 </div> 15 16 <div class="formCheckBox formElement"> 7 17 <div class="formField"> 8 <label for="enableGroupApplyMail "><input id="enableGroupApplyMail" type="checkbox" name="groupApplyMail_enabled" value="1"9 {if $e nabled}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> 10 20 </div> 11 21
