*** empty log message ***
[Packages/TYPO3.CMS.git] / misc / 3.0.0 / oldscripts / board_submit.inc
1 <?php
2 /***************************************************************
3 *  Copyright notice
4 *  
5 *  (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
6 *  All rights reserved
7 *
8 *  This script is part of the Typo3 project. The Typo3 project is 
9 *  free software; you can redistribute it and/or modify
10 *  it under the terms of the GNU General Public License as published by
11 *  the Free Software Foundation; either version 2 of the License, or
12 *  (at your option) any later version.
13
14 *  The GNU General Public License can be found at
15 *  http://www.gnu.org/copyleft/gpl.html.
16 *  A copy is found in the textfile GPL.txt and important notices to the license 
17 *  from the author is found in LICENSE.txt distributed with these scripts.
18 *
19
20 *  This script is distributed in the hope that it will be useful,
21 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 *  GNU General Public License for more details.
24 *
25 *  This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28  * board_submit.inc
29  * 
30  * See TSref document: boardLib.inc / FEDATA section for details on how to use this script.
31  * The static template 'plugin.tt_board' provides a working example of configuration.
32  * 
33  * @author      Kasper Skårhøj <kasper@typo3.com>
34  */
35  
36
37 if (is_object($this))   {
38         if (is_array($this->newData["tt_board"]["NEW"]))        {
39                         // Plain insert of record:
40 //              $this->newData["tt_board"]["NEW"]["datetime"]=time();
41                 $query = $this->getNEWinsert("tt_board", $this->newData["tt_board"]["NEW"]);
42 //debug($query);
43                 $res = mysql(TYPO3_db,$query);
44                 $newId = mysql_insert_id();
45                 echo mysql_error();
46                 $this->clear_cacheCmd(intval($this->newData["tt_board"]["NEW"]["pid"]));
47
48                 $conf = $this->getConf("tt_board");
49                         // Clear specific cache:
50                 if ($conf["clearCacheForPids"]) {
51                         $ccPids=t3lib_div::intExplode(",",$conf["clearCacheForPids"]);
52                         reset($ccPids);
53                         while(list(,$pid)=each($ccPids))        {
54                                 if ($pid > 0)   {$this->clear_cacheCmd($pid);}
55                         }
56                 }
57                 
58 //debug($conf);
59
60                         // Send post to Mailing list ...
61                 if ($conf["sendToMailingList"] && $conf["sendToMailingList."]["email"]) {
62 /*
63         TypoScript for this section (was used for the Typo3 mailing list.
64
65     sendToMailingList=1
66     sendToMailingList {
67       email = typo3@netfielders.de
68       reply = submitmail@typo3.com
69       namePrefix = Typo3Forum/
70       altSubject = Post from www.typo3.com
71     }
72 */
73                         $mConf = $conf["sendToMailingList."];
74                         $maillist_data = $this->newData["tt_board"]["NEW"];
75                         $maillist_recip = $mConf["email"];
76
77                         $maillist_header='From: '.$mConf["namePrefix"].$maillist_data["author"].' <'.$mConf["reply"].'>'.chr(10);
78                         $maillist_header.='Reply-To: '.$mConf["reply"];
79
80
81                                 //  Subject
82                         if ($maillist_data["parent"])   {       // RE:
83                                 $query = "SELECT * FROM tt_board WHERE uid=".intval($maillist_data["parent"]);
84                                 $res = mysql(TYPO3_db,$query);
85                                 $row = mysql_fetch_assoc($res);
86                                 $maillist_subject = "Re: ".$row["subject"]." [#".$maillist_data["parent"]."]";
87                         } else {        // New:
88                                 $maillist_subject =  (trim($maillist_data["subject"]) ? trim(stripslashes($maillist_data["subject"])) : $mConf["altSubject"])." [#".$newId."]";
89                         }
90                 
91                                 // Message
92                         $maillist_msg = stripslashes($maillist_data["subject"]).chr(10).chr(10).stripslashes($maillist_data["message"])."
93 --
94 ".$maillist_data["author"];
95                                 // Send
96                                 
97                         if ($conf["debug"])     {
98                                 debug($maillist_recip,1);
99                                 debug($maillist_subject,1);
100                                 echo nl2br($maillist_msg.chr(10));
101                                 debug($maillist_header,1);
102                         } else {
103                                 mail ($maillist_recip, $maillist_subject, $maillist_msg, $maillist_header);
104                         }
105                 }
106                 
107                 
108                 // Notify me...
109                 if (t3lib_div::GPvar("notify_me") && $conf["notify"])   {
110                         $thescript = parse_url($GLOBALS["HTTP_SERVER_VARS"]["REQUEST_URI"]);
111                         $notifyMe = t3lib_div::uniqueList(str_replace(",".$maillist_data["email"].",", ",", ",".t3lib_div::GPvar("notify_me").","));
112                         
113                         $markersArray=array();
114                         $markersArray["###AUTHOR###"] = trim(stripslashes($this->newData["tt_board"]["NEW"][author]));
115                         $markersArray["###AUTHOR_EMAIL###"] = trim(stripslashes($this->newData["tt_board"]["NEW"][email]));
116                         $markersArray["###HOST###"] = t3lib_div::getIndpEnv("HTTP_HOST");
117                         $markersArray["###URL###"] = 'http://'.t3lib_div::getIndpEnv("HTTP_HOST").$thescript["path"].'?id='.$GLOBALS["TSFE"]->id.'&type='.$GLOBALS["TSFE"]->type.'&no_cache=1&tt_board_uid='.$newId;
118                         
119                         if ($maillist_data["parent"])   {               // If reply and not new thread:
120                                 $msg = t3lib_div::getUrl($GLOBALS["TSFE"]->tmpl->getFileName($conf["newReply."]["msg"]));
121                                 $markersArray["###DID_WHAT###"]= $conf["newReply."]["didWhat"];
122                                 $markersArray["###SUBJECT_PREFIX###"]=$conf["newReply."]["subjectPrefix"];
123                         } else {        // If new thread:
124                                 $msg = t3lib_div::getUrl($GLOBALS["TSFE"]->tmpl->getFileName($conf["newThread."]["msg"]));
125                                 $markersArray["###DID_WHAT###"]= $conf["newThread."]["didWhat"];
126                                 $markersArray["###SUBJECT_PREFIX###"]=$conf["newThread."]["subjectPrefix"];
127                         }
128                         $markersArray["###SUBJECT###"] = stripslashes(strtoupper($this->newData["tt_board"]["NEW"][subject]));
129                         $markersArray["###BODY###"] = t3lib_div::fixed_lgd(stripslashes($this->newData["tt_board"]["NEW"][message]),1000);
130                         
131                         reset($markersArray);
132                         while(list($marker,$markContent)=each($markersArray))   {
133                                 $msg=str_replace($marker,$markContent,$msg);
134                         }
135
136                         $headers=array();
137                         if ($conf["notify_from"])       {$headers[]="FROM: ".$conf["notify_from"];}
138
139                         $msgParts = split(chr(10),$msg,2);
140                         if ($conf["debug"])     {
141                                 debug($notifyMe,1);
142                                 debug($headers,1);
143                                 debug($msgParts);
144                         } else {
145                                 mail ($notifyMe, $msgParts[0], $msgParts[1], implode($headers,chr(10)));
146                         }
147                 }
148         }
149 }
150                 
151 ?>      
152
153
154
155