Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00078 class mod_web_dmail { 00079 var $TSconfPrefix = "mod.web_modules.dmail."; 00080 var $fieldList="uid,name,title,email,phone,www,address,company,city,zip,country,fax,module_sys_dmail_category,module_sys_dmail_html,description"; // Taken from class.t3lib_dmailer.php (,firstname is automatically set), added description 050301 00081 // Internal 00082 var $modList=""; 00083 var $params=array(); 00084 var $perms_clause=""; 00085 var $pageinfo=""; 00086 var $sys_dmail_uid; 00087 var $CMD; 00088 var $pages_uid; 00089 var $categories; 00090 var $id; 00091 var $urlbase; 00092 var $back; 00093 var $noView; 00094 var $url_plain; 00095 var $url_html; 00096 var $mode; 00097 var $implodedParams=array(); 00098 var $userTable; // If set a valid user table is around 00099 00100 function mod_web_dmail ($id,$pageinfo,$perms_clause,$CMD,$sys_dmail_uid,$pages_uid,$modTSconfig) { 00101 $this->id = $id; 00102 $this->pageinfo = $pageinfo; 00103 $this->perms_clause = $perms_clause; 00104 $this->CMD=$CMD; 00105 $this->sys_dmail_uid=$sys_dmail_uid; 00106 $this->pages_uid=$pages_uid; 00107 $this->modList = t3lib_BEfunc::getListOfBackendModules(array("dmail"),$this->perms_clause,$GLOBALS["BACK_PATH"]); 00108 $this->params=$modTSconfig["properties"]; 00109 $this->implodedParams = t3lib_BEfunc::implodeTSParams($this->params); 00110 if ($this->params["userTable"] && is_array($GLOBALS["TCA"][$this->params["userTable"]])) { 00111 $this->userTable = $this->params["userTable"]; 00112 t3lib_div::loadTCA($this->userTable); 00113 } 00114 00115 t3lib_div::loadTCA("sys_dmail"); 00116 00117 00118 // Local lang for dmail module: 00119 include (t3lib_extMgm::extPath("direct_mail")."mod/locallang.php"); 00120 $GLOBALS["LOCAL_LANG"] = t3lib_div::array_merge_recursive_overrule($GLOBALS["LOCAL_LANG"],$LOCAL_LANG_DMAIL); 00121 00122 00123 00124 // debug($this->implodedParams); 00125 // $this->params=t3lib_BEfunc::processParams($this->pageinfo["abstract"]); 00126 // debug($this->params); 00127 } 00128 function createDMail() { 00129 global $TCA; 00130 if ($createMailFrom = t3lib_div::_GP("createMailFrom")) { 00131 // Set default values: 00132 $dmail = array(); 00133 $dmail["sys_dmail"]["NEW"] = array ( 00134 "from_email" => $this->params["from_email"], 00135 "from_name" => $this->params["from_name"], 00136 "replyto_email" => $this->params["replyto_email"], 00137 "replyto_name" => $this->params["replyto_name"], 00138 "return_path" => $this->params["return_path"], 00139 "long_link_rdct_url" => $this->params["long_link_rdct_url"], 00140 "long_link_mode" => $this->params["long_link_mode"], 00141 "organisation" => $this->params["organisation"] 00142 ); 00143 $dmail["sys_dmail"]["NEW"]["sendOptions"] = $TCA["sys_dmail"]["columns"]["sendOptions"]["config"]["default"]; 00144 // If params set, set default values: 00145 if (isset($this->params["sendOptions"])) $dmail["sys_dmail"]["NEW"]["sendOptions"] = $this->params["sendOptions"]; 00146 if (isset($this->params["HTMLParams"])) $dmail["sys_dmail"]["NEW"]["HTMLParams"] = $this->params["HTMLParams"]; 00147 if (isset($this->params["plainParams"])) $dmail["sys_dmail"]["NEW"]["plainParams"] = $this->params["plainParams"]; 00148 00149 // If createMailFrom is an integer, it's an internal page. If not, it's an external url 00150 if (t3lib_div::testInt($createMailFrom)) { 00151 $createFromMailRec = t3lib_BEfunc::getRecord ("pages",$createMailFrom); 00152 if (t3lib_div::inList($GLOBALS["TYPO3_CONF_VARS"]["FE"]["content_doktypes"],$createFromMailRec["doktype"])) { 00153 $dmail["sys_dmail"]["NEW"]["subject"] = $createFromMailRec["title"]; 00154 $dmail["sys_dmail"]["NEW"]["type"] = 0; 00155 $dmail["sys_dmail"]["NEW"]["page"] = $createFromMailRec["uid"]; 00156 $dmail["sys_dmail"]["NEW"]["pid"]=$this->pageinfo["uid"]; 00157 } 00158 } else { 00159 $dmail["sys_dmail"]["NEW"]["subject"] = $createMailFrom; 00160 $dmail["sys_dmail"]["NEW"]["type"] = 1; 00161 $dmail["sys_dmail"]["NEW"]["sendOptions"] = 0; 00162 00163 $dmail["sys_dmail"]["NEW"]["plainParams"] = t3lib_div::_GP("createMailFrom_plainUrl"); 00164 $this->params["enablePlain"] = $dmail["sys_dmail"]["NEW"]["plainParams"] ? 1 : 0; 00165 00166 $dmail["sys_dmail"]["NEW"]["HTMLParams"] = t3lib_div::_GP("createMailFrom_HTMLUrl"); 00167 $this->params["enableHTML"] = $dmail["sys_dmail"]["NEW"]["HTMLParams"] ? 1 : 0; 00168 00169 $dmail["sys_dmail"]["NEW"]["pid"]=$this->pageinfo["uid"]; 00170 } 00171 00172 // Finally the enablePlain and enableHTML flags ultimately determines the sendOptions, IF they are set in the pageTSConfig 00173 if (isset($this->params["enablePlain"])) {if ($this->params["enablePlain"]) {$dmail["sys_dmail"]["NEW"]["sendOptions"]|=1;} else {$dmail["sys_dmail"]["NEW"]["sendOptions"]&=254;}} 00174 if (isset($this->params["enableHTML"])) {if ($this->params["enableHTML"]) {$dmail["sys_dmail"]["NEW"]["sendOptions"]|=2;} else {$dmail["sys_dmail"]["NEW"]["sendOptions"]&=253;}} 00175 00176 if ($dmail["sys_dmail"]["NEW"]["pid"]) { 00177 $tce = t3lib_div::makeInstance("t3lib_TCEmain"); 00178 $tce->stripslashes_values=0; 00179 $tce->start($dmail,Array()); 00180 $tce->process_datamap(); 00181 // debug($tce->substNEWwithIDs["NEW"]); 00182 $this->sys_dmail_uid = $tce->substNEWwithIDs["NEW"]; 00183 } else { 00184 // wrong page, could not... 00185 } 00186 } 00187 } 00188 00189 // ******************** 00190 // MAIN function 00191 // ******************** 00192 function main() { 00193 // debug($this->modList); 00194 if (t3lib_div::inList($GLOBALS["TYPO3_CONF_VARS"]["FE"]["content_doktypes"],$this->pageinfo["doktype"])) { // Regular page, show menu to create a direct mail from this page. 00195 if ($this->pageinfo["group_id"]>0 || $this->pageinfo["hidden"]) { 00196 $theOutput.= $GLOBALS["SOBE"]->doc->section($GLOBALS["LANG"]->getLL("dmail_newsletters"),'<span class="typo3-red">'.$GLOBALS["LANG"]->getLL("dmail_noCreateAccess").'</span>',0,1); 00197 } else { 00198 $isNewsletterPage=0; 00199 if (is_array($this->modList["rows"])) { 00200 reset($this->modList["rows"]); 00201 while(list(,$rData)=each($this->modList["rows"])) { 00202 if ($rData["uid"]==$this->pageinfo["pid"]) { 00203 $isNewsletterPage=1; 00204 } 00205 } 00206 } 00207 if ($isNewsletterPage) { 00208 header('Location: index.php?id='.$this->pageinfo["pid"].'&CMD=displayPageInfo&pages_uid='.$this->pageinfo["uid"].'&SET[dmail_mode]=news'); 00209 exit; 00210 } 00211 } 00212 } elseif ($this->pageinfo["doktype"]==254 && $this->pageinfo["module"]=="dmail") { // Direct mail module 00213 $theOutput.= $this->mailModule_main(); 00214 } elseif ($this->id!=0) { 00215 $theOutput.= $GLOBALS["SOBE"]->doc->section($GLOBALS["LANG"]->getLL("dmail_newsletters"),'<span class="typo3-red">'.$GLOBALS["LANG"]->getLL("dmail_noRegular").'</span>',0,1); 00216 } 00217 00218 if ($this->id!=0) { 00219 $theOutput.=$GLOBALS["SOBE"]->doc->spacer(10); 00220 } 00221 return $theOutput; 00222 } 00223 function mailModule_main() { 00224 // Top menu 00225 $menuHTML = t3lib_BEfunc::getFuncMenu($GLOBALS["SOBE"]->id,"SET[dmail_mode]",$GLOBALS["SOBE"]->MOD_SETTINGS["dmail_mode"],$GLOBALS["SOBE"]->MOD_MENU["dmail_mode"]); 00226 00227 $theOutput.=$GLOBALS["SOBE"]->doc->divider(5); 00228 $theOutput.=$GLOBALS["SOBE"]->doc->section("",$menuHTML); 00229 // $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00230 $mode = $GLOBALS["SOBE"]->MOD_SETTINGS["dmail_mode"]; 00231 00232 if (!$this->sys_dmail_uid || $mode!="direct") { 00233 $this->makeCategories(); 00234 00235 // COMMAND: 00236 switch($this->CMD) { 00237 case "displayPageInfo": 00238 $theOutput.= $this->cmd_displayPageInfo(); 00239 break; 00240 case "displayUserInfo": 00241 $theOutput.= $this->cmd_displayUserInfo(); 00242 break; 00243 case "displayMailGroup": 00244 $result = $this->cmd_compileMailGroup(intval(t3lib_div::_GP("group_uid"))); 00245 $theOutput.= $this->cmd_displayMailGroup($result); 00246 break; 00247 case "displayImport": 00248 $theOutput.= $this->cmd_displayImport(); 00249 break; 00250 default: 00251 $theOutput.= $this->cmd_default($mode); 00252 break; 00253 } 00254 } else { 00255 // Here the single dmail record is shown. 00256 $this->urlbase = substr(t3lib_div::getIndpEnv("TYPO3_REQUEST_DIR"),0,-(strlen(TYPO3_MOD_PATH)+strlen(TYPO3_mainDir))); 00257 $this->sys_dmail_uid = intval($this->sys_dmail_uid); 00258 00259 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_dmail', 'pid='.intval($this->id).' AND uid='.intval($this->sys_dmail_uid).t3lib_BEfunc::deleteClause('sys_dmail')); 00260 00261 $this->noView = 0; 00262 $this->back = '<input type="Submit" value="< BACK" onClick="jumpToUrlD(\'index.php?id='.$this->id.'&sys_dmail_uid='.$this->sys_dmail_uid.'\'); return false;">'; 00263 if($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00264 // Finding the url to fetch content from 00265 switch((string)$row["type"]) { 00266 case 1: 00267 $this->url_html = $row["HTMLParams"]; 00268 $this->url_plain = $row["plainParams"]; 00269 break; 00270 default: 00271 $this->url_html = $this->urlbase."?id=".$row["page"].$row["HTMLParams"]; 00272 $this->url_plain = $this->urlbase."?id=".$row["page"].$row["plainParams"]; 00273 break; 00274 } 00275 if (!($row["sendOptions"]&1) || !$this->url_plain) { // plain 00276 $this->url_plain=""; 00277 } else { 00278 $urlParts = parse_url($this->url_plain); 00279 if (!$urlParts["scheme"]) { 00280 $this->url_plain="http://".$this->url_plain; 00281 } 00282 } 00283 if (!($row["sendOptions"]&2) || !$this->url_html) { // html 00284 $this->url_html=""; 00285 } else { 00286 $urlParts = parse_url($this->url_html); 00287 if (!$urlParts["scheme"]) { 00288 $this->url_html="http://".$this->url_html; 00289 } 00290 } 00291 00292 // COMMAND: 00293 switch($this->CMD) { 00294 case "fetch": 00295 $theOutput.=$this->cmd_fetch($row); 00296 $row = t3lib_befunc::getRecord("sys_dmail",$row["uid"]); 00297 break; 00298 case "prefetch": 00299 $theOutput.=$this->cmd_prefetch($row); 00300 break; 00301 case "testmail": 00302 $theOutput.=$this->cmd_testmail($row); 00303 break; 00304 case "finalmail": 00305 $theOutput.=$this->cmd_finalmail($row); 00306 break; 00307 case "send_mail_test": 00308 case "send_mail_final": 00309 $theOutput.=$this->cmd_send_mail($row); 00310 break; 00311 case "stats": 00312 $theOutput.=$this->cmd_stats($row); 00313 break; 00314 } 00315 if (!$this->noView) { 00316 $theOutput.=$this->directMail_defaultView($row); 00317 } 00318 } 00319 } 00320 return $theOutput; 00321 } 00322 function makeCategories() { 00323 $this->categories = array(); 00324 if (is_array($this->params["categories."])) { 00325 reset($this->params["categories."]); 00326 while(list($pKey,$pVal)=each($this->params["categories."])) { 00327 if (trim($pVal)) { 00328 $catNum = intval($pKey); 00329 if ($catNum>=0 && $catNum<=30) { 00330 $this->categories[$catNum] = $pVal; 00331 } 00332 } 00333 } 00334 } 00335 } 00336 00337 // ******************** 00338 // CMD functions 00339 // ******************** 00340 function cmd_displayPageInfo() { 00341 global $TCA, $LANG; 00342 00343 // Here the dmail list is rendered: 00344 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 00345 'uid,pid,subject,tstamp,issent,renderedsize,attachment,type', 00346 'sys_dmail', 00347 'pid='.intval($this->id).' AND type=0 AND page='.intval($this->pages_uid).t3lib_BEfunc::deleteClause('sys_dmail'), 00348 '', 00349 $GLOBALS['TYPO3_DB']->stripOrderBy($TCA['sys_dmail']['ctrl']['default_sortby']) 00350 ); 00351 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 00352 $onClick = ' onClick="return confirm('.$GLOBALS['LANG']->JScharCode(sprintf($LANG->getLL("nl_l_warning"),$GLOBALS['TYPO3_DB']->sql_num_rows($res))).');"'; 00353 } else { 00354 $onClick = ""; 00355 } 00356 00357 00358 00359 $out=""; 00360 $out.='<a href="#" onClick="'.t3lib_BEfunc::viewOnClick($this->pages_uid,$GLOBALS["BACK_PATH"]).'"><img src="'.$GLOBALS["BACK_PATH"].'gfx/zoom.gif" width="12" height="12" hspace=3 vspace=2 border="0" align=top>'.$LANG->getLL("nl_viewPage").'</a><BR>'; 00361 $out.='<a href="#" onClick="'.t3lib_BEfunc::editOnClick('&edit[pages]['.$this->pages_uid.']=edit&edit_content=1',$GLOBALS["BACK_PATH"],"").'"><img src="'.$GLOBALS["BACK_PATH"].'gfx/edit2.gif" width="11" height="12" hspace=3 vspace=2 border="0" align=top>'.$LANG->getLL("nl_editPage").'</a><BR>'; 00362 $out.='<a href="index.php?id='.$this->id.'&createMailFrom='.$this->pages_uid.'&SET[dmail_mode]=direct"'.$onClick.'><img src="'.$GLOBALS["BACK_PATH"].'/gfx/newmail.gif" width="18" height="16" border="0" align=top>'.$LANG->getLL("nl_createDmailFromPage").'</a><BR>'; 00363 00364 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 00365 $out.="<BR><b>".$LANG->getLL("nl_alreadyBasedOn").":</b><BR><BR>"; 00366 $out.="<table border=0 cellpadding=0 cellspacing=0>"; 00367 $out.='<tr> 00368 <td class="bgColor5">'.fw(" ").'</td> 00369 <td class="bgColor5"><b>'.fw($LANG->getLL("nl_l_subject")." ").'</b></td> 00370 <td class="bgColor5"><b>'.fw($LANG->getLL("nl_l_lastM")." ").'</b></td> 00371 <td class="bgColor5"><b>'.fw($LANG->getLL("nl_l_sent")." ").'</b></td> 00372 <td class="bgColor5"><b>'.fw($LANG->getLL("nl_l_size")." ").'</b></td> 00373 <td class="bgColor5"><b>'.fw($LANG->getLL("nl_l_attach")." ").'</b></td> 00374 <td class="bgColor5"><b>'.fw($LANG->getLL("nl_l_type")." ").'</b></td> 00375 </tr>'; 00376 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00377 $out.='<tr> 00378 <td><img src="'.$GLOBALS["BACK_PATH"].'gfx/i/mail.gif" width=18 height=16 border=0 align="top"></td> 00379 <td>'.$this->linkDMail_record(fw(t3lib_div::fixed_lgd($row["subject"],30)." "),$row["uid"]).'</td> 00380 <td>'.fw(t3lib_BEfunc::date($row["tstamp"])." ").'</td> 00381 <td>'.($row["issent"] ? fw("YES") : "").'</td> 00382 <td>'.($row["renderedsize"] ? fw(t3lib_div::formatSize($row["renderedsize"])." ") : "").'</td> 00383 <td>'.($row["attachment"] ? '<img src="attach.gif" width=9 height=13>' : "").'</td> 00384 <td>'.fw($row["type"] ? $LANG->getLL("nl_l_tUrl") : $LANG->getLL("nl_l_tPage")).'</td> 00385 </tr>'; 00386 00387 } 00388 $out.='</table>'; 00389 } 00390 00391 $theOutput.= $GLOBALS["SOBE"]->doc->section($LANG->getLL("nl_info"),$out,0,1); 00392 $theOutput.= $GLOBALS["SOBE"]->doc->divider(20); 00393 00394 00395 00396 00397 if (is_array($_POST["indata"]["categories"])) { 00398 $data=array(); 00399 reset($_POST["indata"]["categories"]); 00400 while(list($recUid,$recValues)=each($_POST["indata"]["categories"])) { 00401 // debug($recValues); 00402 reset($recValues); 00403 $data["tt_content"][$recUid]["module_sys_dmail_category"]=0; 00404 while(list($k,$b)=each($recValues)) { 00405 if ($b) {$data["tt_content"][$recUid]["module_sys_dmail_category"]|= pow (2,$k);} 00406 } 00407 } 00408 $tce = t3lib_div::makeInstance("t3lib_TCEmain"); 00409 $tce->stripslashes_values=0; 00410 $tce->start($data,Array()); 00411 $tce->process_datamap(); 00412 // debug($data); 00413 } 00414 00415 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 00416 'colPos, CType, uid, header, bodytext, module_sys_dmail_category', 00417 'tt_content', 00418 'pid='.intval($this->pages_uid).t3lib_BEfunc::deleteClause('tt_content').' AND NOT hidden', 00419 '', 00420 'colPos,sorting' 00421 ); 00422 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 00423 $theOutput.= $GLOBALS["SOBE"]->doc->section($LANG->getLL("nl_cat"),$LANG->getLL("nl_cat_msg1")); 00424 } else { 00425 $out=""; 00426 $colPosVal=99; 00427 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00428 $out.='<tr><td colspan=3><img src="clear.gif" width=1 height=15></td></tr>'; 00429 if ($colPosVal!=$row["colPos"]) { 00430 $out.='<tr><td colspan=3 class="bgColor5">'.fw($LANG->getLL("nl_l_column").": <strong>".htmlspecialchars(t3lib_BEfunc::getProcessedValue("tt_content","colPos",$row["colPos"]))."</strong>").'</td></tr>'; 00431 $colPosVal=$row["colPos"]; 00432 } 00433 $out.='<tr>'; 00434 $out.='<td valign=top width=75%>'.fw('<img src="'.$GLOBALS["BACK_PATH"].t3lib_iconWorks::getIcon("tt_content",$row).'" width=18 height=16 border=0 title="'.htmlspecialchars(t3lib_BEfunc::getProcessedValue("tt_content","CType",$row["CType"])).'" align=top> '. 00435 $row["header"].'<BR>'.t3lib_div::fixed_lgd(strip_tags($row["bodytext"]),200).'<BR>').'</td>'; 00436 00437 $out.='<td> </td><td nowrap valign=top>'; 00438 $out_check=""; 00439 if ($row["module_sys_dmail_category"]) { 00440 $out_check.='<font color=red><strong>'.$LANG->getLL("nl_l_ONLY").'</strong></font>'; 00441 } else { 00442 $out_check.='<font color=green><strong>'.$LANG->getLL("nl_l_ALL").'</strong></font>'; 00443 } 00444 $out_check.="<BR>"; 00445 reset($this->categories); 00446 while(list($pKey,$pVal)=each($this->categories)) { 00447 $out_check.='<input type="hidden" name="indata[categories]['.$row["uid"].']['.$pKey.']" value="0"><input type="checkbox" name="indata[categories]['.$row["uid"].']['.$pKey.']" value="1"'.(($row["module_sys_dmail_category"]&pow (2,$pKey)) ?" checked":"").'> '.$pVal.'<BR>'; 00448 } 00449 $out.=fw($out_check).'</td></tr>'; 00450 } 00451 $out='<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>'; 00452 $out.='<input type="hidden" name="pages_uid" value="'.$this->pages_uid.'"><input type="hidden" name="CMD" value="'.$this->CMD.'"><BR><input type="submit" value="'.$LANG->getLL("nl_l_update").'">'; 00453 $theOutput.= $GLOBALS["SOBE"]->doc->section($LANG->getLL("nl_cat"),$LANG->getLL("nl_cat_msg2")."<BR><BR>".$out); 00454 } 00455 return $theOutput; 00456 } 00457 function getCsvValues($str,$sep=",") { 00458 $fh=tmpfile(); 00459 fwrite ($fh, trim($str)); 00460 fseek ($fh,0); 00461 $lines=array(); 00462 while ($data = fgetcsv ($fh, 1000, $sep)) { 00463 $lines[]=$data; 00464 } 00465 return $lines; 00466 } 00467 function rearrangeCsvValues($lines) { 00468 $out=array(); 00469 if (is_array($lines) && count($lines)>0) { 00470 // Analyse if first line is fieldnames. 00471 // Required is it that every value is either 1) found in the list, fieldsList in this class (see top) 2) the value is empty (value omitted then) or 3) the field starts with "user_". 00472 // In addition fields may be prepended with "[code]". This is used if the incoming value is true in which case '+[value]' adds that number to the field value (accummulation) and '=[value]' overrides any existing value in the field 00473 $first = $lines[0]; 00474 $fieldListArr = explode(",",$this->fieldList); 00475 // debug($fieldListArr); 00476 reset($first); 00477 $fieldName=1; 00478 $fieldOrder=array(); 00479 while(list(,$v)=each($first)) { 00480 list($fName,$fConf) = split("\[|\]",$v); 00481 $fName =trim($fName); 00482 $fConf =trim($fConf); 00483 00484 $fieldOrder[]=array($fName,$fConf); 00485 if ($fName && substr($fName,0,5)!="user_" && !in_array($fName,$fieldListArr)) {$fieldName=0; break;} 00486 } 00487 // If not field list, then: 00488 if (!$fieldName) { 00489 $fieldOrder = array(array("name"),array("email")); 00490 } 00491 // debug($fieldOrder); 00492 // debug($fieldName); 00493 //debug($lines); 00494 // Re map values 00495 reset($lines); 00496 if ($fieldName) { 00497 next($lines); // Advance pointer if the first line was field names 00498 } 00499 $c=0; 00500 while(list(,$data)=each($lines)) { 00501 if (count($data)>1 || $data[0]) { // Must be a line with content. This sorts out entries with one key which is empty. Those are empty lines. 00502 // debug($data); 00503 // Traverse fieldOrder and map values over 00504 reset($fieldOrder); 00505 while(list($kk,$fN)=each($fieldOrder)) { 00506 if ($fN[0]) { 00507 if ($fN[1]) { 00508 if (trim($data[$kk])) { // If is true 00509 if (substr($fN[1],0,1)=="=") { 00510 $out[$c][$fN[0]]=trim(substr($fN[1],1)); 00511 } elseif (substr($fN[1],0,1)=="+") { 00512 $out[$c][$fN[0]]+=substr($fN[1],1); 00513 } 00514 } 00515 } else { 00516 $out[$c][$fN[0]]=$data[$kk]; 00517 } 00518 } 00519 } 00520 $c++; 00521 } 00522 } 00523 } 00524 return $out; 00525 } 00526 function rearrangePlainMails($plainMails) { 00527 $out=array(); 00528 if (is_array($plainMails)) { 00529 reset($plainMails); 00530 $c=0; 00531 while(list(,$v)=each($plainMails)) { 00532 $out[$c]["email"]=$v; 00533 $out[$c]["name"]=""; 00534 $c++; 00535 } 00536 } 00537 return $out; 00538 } 00539 function makePidListQuery($table,$pidList,$fields,$cat) { 00540 $cat = intval($cat); 00541 if ($cat>0) { 00542 $addQ = ' AND module_sys_dmail_category&'.$cat.' > 0'; 00543 } else { 00544 $addQ = ''; 00545 } 00546 00547 $query = $GLOBALS['TYPO3_DB']->SELECTquery( 00548 $fields, 00549 $table, 00550 'pid IN ('.$pidList.')'. 00551 $addQ. 00552 t3lib_BEfunc::deleteClause($table). 00553 t3lib_pageSelect::enableFields($table) 00554 ); 00555 00556 return $query; 00557 } 00558 function getIdList($table,$pidList,$cat) { 00559 $query = $this->makePidListQuery($table,$pidList,"uid",$cat); 00560 $res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db,$query); 00561 $outArr = array(); 00562 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00563 $outArr[] = $row["uid"]; 00564 } 00565 return $outArr; 00566 } 00567 function makeStaticListQuery($table,$uid,$fields) { 00568 $query = $GLOBALS['TYPO3_DB']->SELECTquery( 00569 $fields, 00570 $table.',sys_dmail_group,sys_dmail_group_mm', 00571 'sys_dmail_group_mm.uid_local=sys_dmail_group.uid AND 00572 sys_dmail_group_mm.uid_foreign='.$table.'.uid AND sys_dmail_group_mm.tablenames="'.$table.'"'. 00573 t3lib_pageSelect::enableFields($table). // Enable fields includes 'deleted' 00574 t3lib_pageSelect::enableFields("sys_dmail_group") 00575 ); 00576 return $query; 00577 } 00578 function getStaticIdList($table,$uid) { 00579 $query = $this->makeStaticListQuery($table,$uid,$table.".uid"); 00580 $res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db,$query); 00581 $outArr=array(); 00582 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00583 $outArr[]=$row["uid"]; 00584 } 00585 return $outArr; 00586 } 00587 function getMailGroups($list,$parsedGroups) { 00588 $groupIdList = t3lib_div::intExplode(",",$list); 00589 $groups = array(); 00590 00591 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_dmail_group.*', 'sys_dmail_group,pages', ' 00592 sys_dmail_group.uid IN ('.implode(',',$groupIdList).') 00593 AND pages.uid=sys_dmail_group.pid 00594 AND '.$this->perms_clause. 00595 t3lib_BEfunc::deleteClause('pages'). 00596 // t3lib_BEfunc::deleteClause('sys_dmail_group'). // Enable fields includes 'deleted' 00597 // t3lib_pageSelect::enableFields('pages'). // Records should be selected from hidden pages... 00598 t3lib_pageSelect::enableFields('sys_dmail_group')); 00599 00600 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00601 if ($row["type"]==4) { // Other mail group... 00602 if (!in_array($row["uid"],$parsedGroups)) { 00603 $parsedGroups[]=$row["uid"]; 00604 $groups=array_merge($groups,$this->getMailGroups($row["mail_groups"],$parsedGroups)); 00605 } 00606 } else { 00607 $groups[]=$row["uid"]; // Normal mail group, just add to list 00608 } 00609 } 00610 return $groups; 00611 } 00612 function cmd_displayMailGroup($result) { 00613 $count=0; 00614 $idLists = $result["queryInfo"]["id_lists"]; 00615 if (is_array($idLists["tt_address"])) $count+=count($idLists["tt_address"]); 00616 if (is_array($idLists["fe_users"])) $count+=count($idLists["fe_users"]); 00617 if (is_array($idLists["PLAINLIST"])) $count+=count($idLists["PLAINLIST"]); 00618 if (is_array($idLists[$this->userTable])) $count+=count($idLists[$this->userTable]); 00619 00620 $group = t3lib_befunc::getRecord("sys_dmail_group",t3lib_div::_GP("group_uid")); 00621 $out=t3lib_iconWorks::getIconImage("sys_dmail_group",$group,$GLOBALS["BACK_PATH"],'align="top"').$group["title"]."<BR>"; 00622 00623 $lCmd=t3lib_div::_GP("lCmd"); 00624 00625 $mainC = $out."Total number of recipients: <strong>".$count."</strong>"; 00626 if (!$lCmd) { 00627 $mainC.= '<BR>'; 00628 $mainC.= '<BR>'; 00629 $mainC.= '<a href="'.t3lib_div::linkThisScript(array("lCmd"=>"listall")).'">List all recipients</a>'; 00630 } 00631 00632 $theOutput.= $GLOBALS["SOBE"]->doc->section("Recipients from group:",$mainC); 00633 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00634 00635 switch($lCmd) { 00636 case "listall": 00637 $theOutput.= $GLOBALS["SOBE"]->doc->section("ADDRESS TABLE",$this->getRecordList($this->fetchRecordsListValues($idLists["tt_address"],"tt_address"),"tt_address")); 00638 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00639 $theOutput.= $GLOBALS["SOBE"]->doc->section("WEBSITE USERS TABLE",$this->getRecordList($this->fetchRecordsListValues($idLists["fe_users"],"fe_users"),"fe_users")); 00640 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00641 $theOutput.= $GLOBALS["SOBE"]->doc->section("PLAIN LIST",$this->getRecordList($idLists["PLAINLIST"],"default",1)); 00642 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00643 $theOutput.= $GLOBALS["SOBE"]->doc->section($this->userTable." TABLE",$this->getRecordList($this->fetchRecordsListValues($idLists[$this->userTable],$this->userTable),$this->userTable)); 00644 break; 00645 default: 00646 if (t3lib_div::_GP("csv")) { 00647 $csvValue=t3lib_div::_GP("csv"); 00648 if ($csvValue=="PLAINLIST") { 00649 $this->downloadCSV($idLists["PLAINLIST"]); 00650 } elseif (t3lib_div::inList("tt_address,fe_users,".$this->userTable, $csvValue)) { 00651 $this->downloadCSV($this->fetchRecordsListValues($idLists[$csvValue],$csvValue,$this->fieldList.",tstamp")); 00652 } 00653 } else { 00654 $theOutput.= $GLOBALS["SOBE"]->doc->section("ADDRESS TABLE","Recipients: ".(is_array($idLists["tt_address"])?count($idLists["tt_address"]):0).'<BR><a href="'.t3lib_div::linkThisScript(array("csv"=>"tt_address")).'">Download CSV file</a>'); 00655 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00656 $theOutput.= $GLOBALS["SOBE"]->doc->section("WEBSITE USERS TABLE","Recipients: ".(is_array($idLists["fe_users"])?count($idLists["fe_users"]):0).'<BR><a href="'.t3lib_div::linkThisScript(array("csv"=>"fe_users")).'">Download CSV file</a>'); 00657 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00658 $theOutput.= $GLOBALS["SOBE"]->doc->section("PLAIN LIST","Recipients: ".(is_array($idLists["PLAINLIST"])?count($idLists["PLAINLIST"]):0).'<BR><a href="'.t3lib_div::linkThisScript(array("csv"=>"PLAINLIST")).'">Download CSV file</a>'); 00659 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00660 $theOutput.= $GLOBALS["SOBE"]->doc->section($this->userTable." TABLE","Recipients: ".(is_array($idLists[$this->userTable])?count($idLists[$this->userTable]):0).'<BR><a href="'.t3lib_div::linkThisScript(array("csv"=>$this->userTable)).'">Download CSV file</a>'); 00661 } 00662 break; 00663 } 00664 return $theOutput; 00665 } 00666 function downloadCSV($idArr) { 00667 $lines=array(); 00668 #debug($idArr); 00669 if (is_array($idArr) && count($idArr)) { 00670 reset($idArr); 00671 $lines[]=t3lib_div::csvValues(array_keys(current($idArr)),",",""); 00672 00673 reset($idArr); 00674 while(list($i,$rec)=each($idArr)) { 00675 // debug(t3lib_div::csvValues($rec),1); 00676 $lines[]=t3lib_div::csvValues($rec); 00677 } 00678 } 00679 00680 $filename="DirectMail_export_".date("dmy-Hi").".csv"; 00681 $mimeType = "application/octet-stream"; 00682 Header("Content-Type: ".$mimeType); 00683 Header("Content-Disposition: attachment; filename=".$filename); 00684 echo implode(chr(13).chr(10),$lines); 00685 exit; 00686 } 00687 function cmd_displayMailGroup_test($result) { 00688 $count=0; 00689 $idLists = $result["queryInfo"]["id_lists"]; 00690 $out=""; 00691 if (is_array($idLists["tt_address"])) {$out.=$this->getRecordList($this->fetchRecordsListValues($idLists["tt_address"],"tt_address"),"tt_address");} 00692 if (is_array($idLists["fe_users"])) {$out.=$this->getRecordList($this->fetchRecordsListValues($idLists["fe_users"],"fe_users"),"fe_users");} 00693 if (is_array($idLists["PLAINLIST"])) {$out.=$this->getRecordList($idLists["PLAINLIST"],"default",1);} 00694 if (is_array($idLists[$this->userTable])) {$out.=$this->getRecordList($this->fetchRecordsListValues($idLists[$this->userTable],$this->userTable),$this->userTable);} 00695 00696 return $out; 00697 } 00698 function cmd_compileMailGroup($group_uid,$makeIdLists=1) { 00699 // $makeIdLists: Set to 0 if you don't want the list of table ids to be collected but only the queries to be stored. 00700 $queries=array(); 00701 $id_lists=array(); 00702 if ($group_uid) { 00703 $mailGroup=t3lib_BEfunc::getRecord("sys_dmail_group",$group_uid); 00704 if (is_array($mailGroup) && $mailGroup["pid"]==$this->id) { 00705 $head = '<img src="'.$GLOBALS["BACK_PATH"].t3lib_iconWorks::getIcon("sys_dmail_group").'" width=18 height=16 border=0 align="top">'.t3lib_div::fixed_lgd($mailGroup["title"],30)."<BR>"; 00706 $theOutput.=$head; 00707 switch($mailGroup["type"]) { 00708 case 0: // From pages 00709 $thePages = $mailGroup["pages"] ? $mailGroup["pages"] : $this->id; // use current page if no else 00710 $pages = t3lib_div::intExplode(",",$thePages); // Explode the pages 00711 reset($pages); 00712 $pageIdArray=array(); 00713 while(list(,$pageUid)=each($pages)) { 00714 if ($pageUid>0) { 00715 $pageinfo = t3lib_BEfunc::readPageAccess($pageUid,$this->perms_clause); 00716 if (is_array($pageinfo)) { 00717 $info["fromPages"][]=$pageinfo; 00718 $pageIdArray[]=$pageUid; 00719 if ($mailGroup["recursive"]) { 00720 $pageIdArray=array_merge($pageIdArray,$GLOBALS["SOBE"]->getRecursiveSelect($pageUid,$this->perms_clause)); 00721 } 00722 } 00723 } 00724 00725 } 00726 // Remove any duplicates 00727 $pageIdArray=array_unique($pageIdArray); 00728 $pidList = implode(",",$pageIdArray); 00729 $info["recursive"]=$mailGroup["recursive"]; 00730 // debug($pageIdArray); 00731 // debug($info); 00732 // Make queries 00733 if ($pidList) { 00734 $whichTables = intval($mailGroup["whichtables"]); 00735 if ($whichTables&1) { // tt_address 00736 $queries["tt_address"]=$this->makePidListQuery("tt_address",$pidList,"*",$mailGroup["select_categories"]); 00737 if ($makeIdLists) $id_lists["tt_address"]=$this->getIdList("tt_address",$pidList,$mailGroup["select_categories"]); 00738 } 00739 if ($whichTables&2) { // tt_address 00740 $queries["fe_users"]=$this->makePidListQuery("fe_users",$pidList,"*",$mailGroup["select_categories"]); 00741 if ($makeIdLists) $id_lists["fe_users"]=$this->getIdList("fe_users",$pidList,$mailGroup["select_categories"]); 00742 } 00743 if ($this->userTable && ($whichTables&4)) { // tt_address 00744 $queries[$this->userTable]=$this->makePidListQuery($this->userTable,$pidList,"*",$mailGroup["select_categories"]); 00745 if ($makeIdLists) $id_lists[$this->userTable]=$this->getIdList($this->userTable,$pidList,$mailGroup["select_categories"]); 00746 } 00747 } 00748 // debug($queries); 00749 // debug($id_lists); 00750 break; 00751 case 1: // List of mails 00752 if ($mailGroup["csv"]==1) { 00753 $recipients = $this->rearrangeCsvValues($this->getCsvValues($mailGroup["list"])); 00754 // debug($recipients); 00755 } else { 00756 $recipients = $this->rearrangePlainMails(array_unique(split("[[:space:],;]+",$mailGroup["list"]))); 00757 // debug($recipients); 00758 } 00759 $id_lists["PLAINLIST"] = $this->cleanPlainList($recipients); 00760 // debug($id_lists); 00761 break; 00762 case 2: // Static MM list 00763 $queries["tt_address"] = $this->makeStaticListQuery("tt_address",$group_uid,"tt_address.*"); 00764 if ($makeIdLists) $id_lists["tt_address"] = $this->getStaticIdList("tt_address",$group_uid); 00765 $queries["fe_users"] = $this->makeStaticListQuery("fe_users",$group_uid,"fe_users.*"); 00766 if ($makeIdLists) $id_lists["fe_users"] = $this->getStaticIdList("fe_users",$group_uid); 00767 if ($this->userTable) { 00768 $queries[$this->userTable] = $this->makeStaticListQuery($this->userTable,$group_uid,$this->userTable."*"); 00769 if ($makeIdLists) $id_lists[$this->userTable] = $this->getStaticIdList($this->userTable,$group_uid); 00770 } 00771 // debug($queries); 00772 // debug($id_lists); 00773 break; 00774 case 3: // QUERY 00775 //$theOutput.=$this->cmd_query($group_uid); 00776 $theOutput.=$GLOBALS["SOBE"]->doc->section("Special Query","UNDER CONSTRUCTION..."); 00777 break; 00778 case 4: // 00779 $groups = array_unique($this->getMailGroups($mailGroup["mail_groups"],array($mailGroup["uid"]))); 00780 reset($groups); 00781 $queries=array(); 00782 $id_lists=array(); 00783 while(list(,$v)=each($groups)) { 00784 $collect=$this->cmd_compileMailGroup($v); 00785 if (is_array($collect["queryInfo"]["queries"])) { 00786 $queries=t3lib_div::array_merge_recursive_overrule($queries,$collect["queryInfo"]["queries"]); 00787 } 00788 if (is_array($collect["queryInfo"]["id_lists"])) { 00789 $id_lists=t3lib_div::array_merge_recursive_overrule($id_lists,$collect["queryInfo"]["id_lists"]); 00790 } 00791 } 00792 // Make unique entries 00793 if (is_array($id_lists["tt_address"])) $id_lists["tt_address"] = array_unique($id_lists["tt_address"]); 00794 if (is_array($id_lists["fe_users"])) $id_lists["fe_users"] = array_unique($id_lists["fe_users"]); 00795 if (is_array($id_lists[$this->userTable]) && $this->userTable) $id_lists[$this->userTable] = array_unique($id_lists[$this->userTable]); 00796 if (is_array($id_lists["PLAINLIST"])) {$id_lists["PLAINLIST"] = $this->cleanPlainList($id_lists["PLAINLIST"]);} 00797 00798 // debug($id_lists); 00799 // debug($queries); 00800 00801 // debug($groups); 00802 break; 00803 } 00804 // debug($mailGroup); 00805 } 00806 } 00807 $outputArray=array( 00808 "code"=>$theOutput, 00809 "queryInfo" => array("id_lists"=>$id_lists, "queries"=>$queries) 00810 ); 00811 return $outputArray; 00812 } 00813 function cleanPlainList($plainlist) { 00814 reset($plainlist); 00815 $emails=array(); 00816 while(list($k,$v)=each($plainlist)) { 00817 if (in_array($v["email"],$emails)) { unset($plainlist[$k]); } 00818 $emails[]=$v["email"]; 00819 } 00820 return $plainlist; 00821 } 00822 function cmd_query($dgUid) { 00823 $GLOBALS["SOBE"]->MOD_SETTINGS=array(); 00824 $GLOBALS["SOBE"]->MOD_SETTINGS["dmail_queryConfig"]=serialize($_POST["dmail_queryConfig"]); 00825 $GLOBALS["SOBE"]->MOD_SETTINGS["dmail_queryTable"]=$_POST["SET"]["dmail_queryTable"]; 00826 $GLOBALS["SOBE"]->MOD_SETTINGS["dmail_search_query_smallparts"]=1; 00827 00828 $qGen = t3lib_div::makeInstance("mailSelect"); 00829 $qGen->init("queryConfig",$GLOBALS["SOBE"]->MOD_SETTINGS["queryTable"]); 00830 $qGen->noWrap=""; 00831 if ($this->userTable) $qGen->allowedTables[]=$this->userTable; 00832 $tmpCode=$qGen->makeSelectorTable($GLOBALS["SOBE"]->MOD_SETTINGS,"table,query"); 00833 $tmpCode.='<input type="hidden" name="CMD" value="displayMailGroup"><input type="hidden" name="group_uid" value="'.$dgUid.'">'; 00834 $theOutput.=$GLOBALS["SOBE"]->doc->section("Make Query",$tmpCode); 00835 00836 // $theOutput=$qGen->getFormElements(); 00837 // $theOutput.="<HR>"; 00838 00839 00840 $out = $qGen->getQuery($qGen->queryConfig); 00841 $theOutput.=$GLOBALS["SOBE"]->doc->section("QUERY",$out); 00842 00843 return $theOutput; 00844 } 00845 function importRecords_sort($records,$syncSelect,$tstampFlag) { 00846 reset($records); 00847 $kinds=array(); 00848 while(list(,$recdata)=each($records)) { 00849 if ($syncSelect && !t3lib_div::testInt($syncSelect)) { 00850 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,tstamp', 'tt_address', 'pid='.intval($this->id).' AND '.$syncSelect.'="'.$GLOBALS['TYPO3_DB']->quoteStr($recdata[$syncSelect], 'tt_address').'"'.t3lib_befunc::deleteClause('tt_address'), '', '', '1'); 00851 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00852 if ($tstampFlag) { 00853 if ($row["tstamp"]>intval($recdata["tstamp"])) { 00854 $kinds["newer_version_detected"][]=$recdata; 00855 } else {$kinds["update"][$row["uid"]]=$recdata;} 00856 } else {$kinds["update"][$row["uid"]]=$recdata;} 00857 } else {$kinds["insert"][]=$recdata;} // Import if no row found 00858 } else {$kinds["insert"][]=$recdata;} 00859 } 00860 return $kinds; 00861 } 00862 function importRecords($categorizedRecords,$removeExisting) { 00863 $cmd = array(); 00864 $data = array(); 00865 if ($removeExisting) { // Deleting: 00866 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tt_address', 'pid='.intval($this->id).t3lib_BEfunc::deleteClause('tt_address')); 00867 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00868 $cmd["tt_address"][$row["uid"]]["delete"] = 1; 00869 } 00870 } 00871 if (is_array($categorizedRecords["insert"])) { 00872 reset($categorizedRecords["insert"]); 00873 $c=0; 00874 while(list(,$rec)=each($categorizedRecords["insert"])) { 00875 $c++; 00876 $data["tt_address"]["NEW".$c] = $rec; 00877 $data["tt_address"]["NEW".$c]["pid"] = $this->id; 00878 } 00879 } 00880 if (is_array($categorizedRecords["update"])) { 00881 reset($categorizedRecords["update"]); 00882 $c=0; 00883 while(list($rUid,$rec)=each($categorizedRecords["update"])) { 00884 $c++; 00885 $data["tt_address"][$rUid]=$rec; 00886 } 00887 } 00888 00889 $tce = t3lib_div::makeInstance("t3lib_TCEmain"); 00890 $tce->stripslashes_values=0; 00891 $tce->enableLogging=0; 00892 $tce->start($data,$cmd); 00893 $tce->process_datamap(); 00894 $tce->process_cmdmap(); 00895 /* debug($data); 00896 debug($cmd); 00897 */ 00898 } 00899 function fetchRecordsListValues($listArr,$table,$fields="uid,name,email") { 00900 $count = 0; 00901 $outListArr = array(); 00902 if (is_array($listArr) && count($listArr)) { 00903 $idlist = implode(",",$listArr); 00904 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, 'uid IN ('.$idlist.')'.t3lib_befunc::deleteClause($table)); 00905 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00906 $outListArr[$row["uid"]] = $row; 00907 } 00908 } 00909 return $outListArr; 00910 } 00911 function getRecordList($listArr,$table,$dim=0,$editLinkFlag=1) { 00912 $count=0; 00913 $lines=array(); 00914 $out=""; 00915 if (is_array($listArr)) { 00916 $count=count($listArr); 00917 reset($listArr); 00918 while(list(,$row)=each($listArr)) { 00919 if ($editLinkFlag) { 00920 $editLink = '<td><a href="index.php?id='.$this->id.'&CMD=displayUserInfo&table='.$table.'&uid='.$row["uid"].'"><img src="'.$GLOBALS["BACK_PATH"].'gfx/zoom2.gif" width=12 height=12 hspace=5 border=0 title="Edit" align="top"></a></td>'; 00921 // debug($editLink,1); 00922 // break; 00923 // debug($editLink,1); 00924 // $editLink.= '<td>'.($row["module_sys_dmail_html"]?"YES":"").'</td>'; 00925 } 00926 $lines[]='<tr class="bgColor4"> 00927 <td>'.t3lib_iconWorks::getIconImage($table,array(),$GLOBALS["BACK_PATH"],'title="'.($row["uid"]?"uid: ".$row["uid"]:"").'"',$dim).'</td> 00928 '.$editLink.' 00929 <td nowrap> '.$row["email"].' </td> 00930 <td nowrap> '.$row["name"].' </td> 00931 </tr>'; 00932 } 00933 } 00934 if (count($lines)) { 00935 $out="Number of records: <strong>".$count."</strong><BR>"; 00936 $out.='<table border=0 cellspacing=1 cellpadding=0>'.implode(chr(10),$lines).'</table>'; 00937 } 00938 return $out; 00939 } 00940 function cmd_displayImport() { 00941 $indata = t3lib_div::_GP("CSV_IMPORT"); 00942 if (is_array($indata)) { 00943 $records = $this->rearrangeCsvValues($this->getCsvValues($indata["csv"],$indata["sep"])); 00944 $categorizedRecords = $this->importRecords_sort($records,$indata["syncSelect"],$indata["tstamp"]); 00945 00946 $theOutput.= $GLOBALS["SOBE"]->doc->section("INSERT RECORDS",$this->getRecordList($categorizedRecords["insert"],"tt_address",1)); 00947 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00948 $theOutput.= $GLOBALS["SOBE"]->doc->section("UPDATE RECORDS",$this->getRecordList($categorizedRecords["update"],"tt_address",1)); 00949 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00950 $theOutput.= $GLOBALS["SOBE"]->doc->section("NOT UPDATED - NEWER VERSION IN DATABASE",$this->getRecordList($categorizedRecords["newer_version_detected"],"tt_address",1)); 00951 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 00952 00953 if ($indata["doImport"]) { 00954 $this->importRecords($categorizedRecords,$indata["syncSelect"]==-1?1:0); 00955 } 00956 } 00957 if (!is_array($indata) || $indata["test_only"]) { 00958 $importButton=is_array($indata) ? '<input type="submit" name="CSV_IMPORT[doImport]" value="Import(!)">' : ''; 00959 // Selector, mode 00960 if (!isset($indata["syncSelect"])) $indata["syncSelect"]="email"; 00961 $opt=array(); 00962 $opt[]='<option value="email"'.($indata["syncSelect"]=="email"?" selected":"").'>Email</option>'; 00963 $opt[]='<option value="name"'.($indata["syncSelect"]=="name"?" selected":"").'>Name</option>'; 00964 $opt[]='<option value="uid"'.($indata["syncSelect"]=="uid"?" selected":"").'>uid</option>'; 00965 $opt[]='<option value="phone"'.($indata["syncSelect"]=="phone"?" selected":"").'>phone</option>'; 00966 $opt[]='<option value="0"'.($indata["syncSelect"]=="0"?" selected":"").'>[Import ALL]</option>'; 00967 $opt[]='<option value="-1"'.($indata["syncSelect"]=="-1"?" selected":"").'>[Import ALL and Remove Existing]</option>'; 00968 $selectSync='<select name="CSV_IMPORT[syncSelect]">'.implode("",$opt).'</select>'; 00969 // Selector, sep 00970 if (!isset($indata["sep"])) $indata["sep"]=","; 00971 $opt=array(); 00972 $opt[]='<option value=","'.($indata["sep"]==","?" selected":"").'>, (comma)</option>'; 00973 $opt[]='<option value=";"'.($indata["sep"]==";"?" selected":"").'>; (semicolon)</option>'; 00974 $opt[]='<option value=":"'.($indata["sep"]==":"?" selected":"").'>: (colon)</option>'; 00975 $sepSync='<select name="CSV_IMPORT[sep]">'.implode("",$opt).'</select>'; 00976 00977 $out='<textarea name="CSV_IMPORT[csv]" rows="25" wrap="off"'.$GLOBALS["SOBE"]->doc->formWidthText(48,"","off").'>'.t3lib_div::formatForTextarea($indata["csv"]).'</textarea><BR> 00978 <br> 00979 <strong>Rules:</strong><hr> 00980 Update existing records based on the '.$selectSync.'-field being unique. Import the rest. 00981 <hr> 00982 <input type="checkbox" name="CSV_IMPORT[tstamp]" value="1"'.(($importButton && !$indata["tstamp"])?"":" checked").'>Update only records where the time stamp (tstamp) is NOT newer than the imported. 00983 <hr> 00984 '.$sepSync.' Separator character. 00985 <hr> 00986 <input type="submit" name="CSV_IMPORT[test_only]" value="Test import (no data written)"> '.$importButton.' 00987 <input type="hidden" name="CMD" value="displayImport"> 00988 '; 00989 } 00990 $theOutput.= $GLOBALS["SOBE"]->doc->section("IMPORT CSV into 'ADDRESS' table",$out); 00991 return $theOutput; 00992 } 00993 function cmd_displayUserInfo() { 00994 $uid = intval(t3lib_div::_GP("uid")); 00995 00996 unset($row); 00997 $table=t3lib_div::_GP("table"); 00998 00999 switch($table) { 01000 case "tt_address": 01001 case "fe_users": 01002 if (is_array($_POST["indata"])) { 01003 $data=array(); 01004 if (is_array($_POST["indata"]["categories"])) { 01005 reset($_POST["indata"]["categories"]); 01006 while(list($recUid,$recValues)=each($_POST["indata"]["categories"])) { 01007 reset($recValues); 01008 $data[$table][$uid]["module_sys_dmail_category"]=0; 01009 while(list($k,$b)=each($recValues)) { 01010 if ($b) {$data[$table][$uid]["module_sys_dmail_category"]|= pow (2,$k);} 01011 } 01012 } 01013 } 01014 //debug($data[$table][$uid]["module_sys_dmail_category"]); 01015 // debug($_POST["indata"]["categories"]); 01016 01017 $data[$table][$uid]["module_sys_dmail_html"] = $_POST["indata"]["html"] ? 1 : 0; 01018 $tce = t3lib_div::makeInstance("t3lib_TCEmain"); 01019 $tce->stripslashes_values=0; 01020 $tce->start($data,Array()); 01021 $tce->process_datamap(); 01022 // debug($data); 01023 } 01024 break; 01025 } 01026 01027 switch($table) { 01028 case "tt_address": 01029 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tt_address.*', 'tt_address,pages', 'pages.uid=tt_address.pid AND tt_address.uid='.intval($uid).' AND '.$this->perms_clause.t3lib_BEfunc::deleteClause('tt_address').t3lib_BEfunc::deleteClause('pages')); 01030 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 01031 break; 01032 case "fe_users": 01033 01034 break; 01035 } 01036 if (is_array($row)) { 01037 $Eparams="&edit[".$table."][".$row["uid"]."]=edit"; 01038 $out=""; 01039 $out.='<img src="'.$GLOBALS["BACK_PATH"].t3lib_iconWorks::getIcon($table,$row).'" width=18 height=16 border=0 title="'.htmlspecialchars(t3lib_BEfunc::getRecordPath ($row["pid"],$this->perms_clause,40)).'" align=top>'.$row["name"].htmlspecialchars(" <".$row["email"].">"); 01040 $out.=' <A HREF="#" onClick="'.t3lib_BEfunc::editOnClick($Eparams,$GLOBALS["BACK_PATH"],"").'"><img src="'.$GLOBALS["BACK_PATH"].'gfx/edit2.gif" width=11 height=12 hspace=2 border=0 title="Edit" align="top">'.fw("<B>EDIT</B>").'</a>'; 01041 $theOutput.= $GLOBALS["SOBE"]->doc->section("Subscriber info",$out); 01042 01043 01044 01045 $out=""; 01046 $out_check=""; 01047 reset($this->categories); 01048 while(list($pKey,$pVal)=each($this->categories)) { 01049 $out_check.='<input type="hidden" name="indata[categories]['.$row["uid"].']['.$pKey.']" value="0"><input type="checkbox" name="indata[categories]['.$row["uid"].']['.$pKey.']" value="1"'.(($row["module_sys_dmail_category"]&pow(2,$pKey)) ?" checked":"").'> '.$pVal.'<BR>'; 01050 } 01051 $out_check.='<BR><BR><input type="hidden" name="indata[html]" value="0"><input type="checkbox" name="indata[html]" value="1"'.($row["module_sys_dmail_html"]?" checked":"").'> '; 01052 $out_check.='Receive HTML based mails<BR>'; 01053 $out.=fw($out_check); 01054 01055 $out.='<input type="hidden" name="table" value="'.$table.'"><input type="hidden" name="uid" value="'.$uid.'"><input type="hidden" name="CMD" value="'.$this->CMD.'"><BR><input type="submit" value="Update profile settings">'; 01056 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 01057 $theOutput.= $GLOBALS["SOBE"]->doc->section("Subscriber profile","Set categories of interest for the subscriber.<BR>".$out); 01058 } 01059 return $theOutput; 01060 } 01061 01065 function cmd_default($mode) { 01066 global $TCA,$LANG; 01067 01068 switch($mode) { 01069 case "direct": 01070 // Here the dmail list is rendered: 01071 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 01072 'uid,pid,subject,tstamp,issent,renderedsize,attachment,type', 01073 'sys_dmail', 01074 'pid='.intval($this->id).' AND scheduled=0'.t3lib_BEfunc::deleteClause('sys_dmail'), 01075 '', 01076 $GLOBALS['TYPO3_DB']->stripOrderBy($TCA['sys_dmail']['ctrl']['default_sortby']) 01077 ); 01078 $out=""; 01079 $out.='<tr> 01080 <td class="bgColor5">'.fw(" ").'</td> 01081 <td class="bgColor5"><b>'.fw("Subject"." ").'</b></td> 01082 <td class="bgColor5"><b>'.fw("Last mod."." ").'</b></td> 01083 <td class="bgColor5"><b>'.fw("Sent?"." ").'</b></td> 01084 <td class="bgColor5"><b>'.fw("Size"." ").'</b></td> 01085 <td class="bgColor5"><b>'.fw("Attach."." ").'</b></td> 01086 <td class="bgColor5"><b>'.fw("Type"." ").'</b></td> 01087 </tr>'; 01088 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01089 $out.='<tr> 01090 <td><img src="'.$GLOBALS["BACK_PATH"].'gfx/i/mail.gif" width=18 height=16 border=0 align="top"></td> 01091 <td>'.$this->linkDMail_record(fw(t3lib_div::fixed_lgd($row["subject"],30)." "),$row["uid"]).'</td> 01092 <td>'.fw(t3lib_BEfunc::date($row["tstamp"])." ").'</td> 01093 <td>'.($row["issent"] ? fw("YES") : "").'</td> 01094 <td>'.($row["renderedsize"] ? fw(t3lib_div::formatSize($row["renderedsize"])." ") : "").'</td> 01095 <td>'.($row["attachment"] ? '<img src="attach.gif" width=9 height=13>' : "").'</td> 01096 <td>'.fw($row["type"] ? 'EXT URL' : 'PAGE').'</td> 01097 </tr>'; 01098 01099 } 01100 $out='<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>'; 01101 $theOutput.= $GLOBALS["SOBE"]->doc->section($LANG->getLL("dmail_dovsk_selectDmail"),$out,1,1); 01102 01103 01104 // Find all newsletters NOT created as DMAILS: // NOTICE: Hardcoded PID - hardly what we want! 01105 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pages.uid,pages.title', 'pages LEFT JOIN sys_dmail ON pages.uid=sys_dmail.page', 'sys_dmail.page is NULL AND pages.pid=47'.t3lib_BEfunc::deleteClause('sys_dmail').t3lib_BEfunc::deleteClause('pages')); 01106 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 01107 $out = $LANG->getLL("dmail_msg1_crFromNL"); 01108 } else { 01109 $out = ""; 01110 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01111 $out.= '<nobr><a href="index.php?id='.$this->id.'&createMailFrom='.$row["uid"].'&SET[dmail_mode]=direct"><img src="'.$GLOBALS["BACK_PATH"].t3lib_iconWorks::getIcon("pages",$row).'" width=18 height=16 border=0 title="'.htmlspecialchars(t3lib_BEfunc::getRecordPath ($row["uid"],$this->perms_clause,20)).'" align=top>'. 01112 $row["title"]."</a></nobr><BR>"; 01113 } 01114 } 01115 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 01116 $theOutput.= $GLOBALS["SOBE"]->doc->section($LANG->getLL("dmail_dovsk_crFromNL"),$out,1,1); 01117 01118 01119 // Create 01120 $out=' 01121 HTML URL:<br> 01122 <input type="text" value="http://" name="createMailFrom_HTMLUrl"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(40).'><br> 01123 Plain Text URL:<br> 01124 <input type="text" value="http://" name="createMailFrom_plainUrl"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(40).'><br> 01125 Subject:<br> 01126 <input type="text" value="[write subject]" name="createMailFrom" onfocus="this.value=\'\';"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(40).'><br> 01127 <input type="submit" value="'.$LANG->getLL("dmail_createMail").'"> 01128 '; 01129 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 01130 $theOutput.= $GLOBALS["SOBE"]->doc->section($LANG->getLL("dmail_dovsk_crFromUrl"),$out,1,1); 01131 01132 01133 break; 01134 case "news": 01135 // Here the list of subpages, news, is rendered: 01136 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,doktype,title,abstract', 'pages', 'pid='.intval($this->id).' AND doktype IN ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].') AND '.$this->perms_clause.t3lib_BEfunc::deleteClause('pages').t3lib_pageSelect::enableFields('pages'), '', 'sorting'); 01137 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 01138 $theOutput.= $GLOBALS["SOBE"]->doc->section($LANG->getLL("nl_select"),$LANG->getLL("nl_select_msg1"),0,1); 01139 } else { 01140 $out=""; 01141 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01142 $out.='<nobr><a href="index.php?id='.$this->id.'&CMD=displayPageInfo&pages_uid='.$row["uid"].'&SET[dmail_mode]=news"><img src="'.$GLOBALS["BACK_PATH"].t3lib_iconWorks::getIcon("pages",$row).'" width=18 height=16 border=0 title="'.htmlspecialchars(t3lib_BEfunc::getRecordPath ($row["uid"],$this->perms_clause,20)).'" align=top>'. 01143 $row["title"]."</a></nobr><BR>"; 01144 } 01145 $theOutput.= $GLOBALS["SOBE"]->doc->section($LANG->getLL("nl_select"),$out,0,1); 01146 } 01147 01148 // Create a new page 01149 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 01150 $theOutput.= $GLOBALS["SOBE"]->doc->section($LANG->getLL("nl_create"),'<a href="#" onClick="'.t3lib_BEfunc::editOnClick('&edit[pages]['.$this->id.']=new&edit[tt_content][prev]=new',$GLOBALS["BACK_PATH"],"").'"><b>'.$LANG->getLL("nl_create_msg1").'</b></a>',0,1); 01151 break; 01152 case "recip": 01153 // Create a query... 01154 // $theOutput.= $GLOBALS["SOBE"]->doc->spacer(10); 01155 01156 // $theOutput.= $GLOBALS["SOBE"]->doc->section("qUERY...",'<nobr><a href="index.php?id='.$this->id.'&CMD=displayQuery">QUERY</a></nobr><BR>'); 01157 // Display mailer engine status 01158 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,pid,title,description,type', 'sys_dmail_group', 'pid='.intval($this->id).t3lib_BEfunc::deleteClause('sys_dmail_group'), '', $GLOBALS['TYPO3_DB']->stripOrderBy($TCA['sys_dmail_group']['ctrl']['default_sortby'])); 01159 $out = ""; 01160 $out.='<tr> 01161 <td class="bgColor5" colspan=2>'.fw(" ").'</td> 01162 <td class="bgColor5"><b>'.fw($LANG->sL(t3lib_BEfunc::getItemLabel("sys_dmail_group","title"))).'</b></td> 01163 <td class="bgColor5"><b>'.fw($LANG->sL(t3lib_BEfunc::getItemLabel("sys_dmail_group","type"))).'</b></td> 01164 <td class="bgColor5"><b>'.fw($LANG->sL(t3lib_BEfunc::getItemLabel("sys_dmail_group","description"))).'</b></td> 01165 </tr>'; 01166 $TDparams=' valign=top'; 01167 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01168 $out.='<tr> 01169 <td'.$TDparams.' nowrap><img src="'.$GLOBALS["BACK_PATH"].t3lib_iconWorks::getIcon("sys_dmail_group").'" width=18 height=16 border=0 align="top"></td> 01170 <td'.$TDparams.'>'.$this->editLink("sys_dmail_group",$row["uid"]).'</td> 01171 <td'.$TDparams.' nowrap>'.$this->linkRecip_record(fw("<strong>".t3lib_div::fixed_lgd($row["title"],30)."</strong> "),$row["uid"]).'</td> 01172 <td'.$TDparams.' nowrap>'.fw(htmlspecialchars(t3lib_BEfunc::getProcessedValue("sys_dmail_group","type",$row["type"]))." ").'</td> 01173 <td'.$TDparams.'>'.fw(htmlspecialchars(t3lib_BEfunc::getProcessedValue("sys_dmail_group","description",$row["description"]))." ").'</td> 01174 </tr>'; 01175 01176 } 01177 $out='<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>'; 01178 01179 $theOutput.= $GLOBALS["SOBE"]->doc->section("Select a Mail Group",$out,0,1); 01180 01181 // New: 01182 $out='<a href="#" onClick="'.t3lib_BEfunc::editOnClick('&edit[sys_dmail_group]['.$this->id.']=new',$GLOBALS["BACK_PATH"],"").'">'.t3lib_iconWorks::getIconImage("sys_dmail_group",array(),$GLOBALS["BACK_PATH"],'align=top').'Create new?</a>'; 01183 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 01184 $theOutput.= $GLOBALS["SOBE"]->doc->section("New mail group?",$out); 01185 01186 // Import 01187 $out='<a href="index.php?id='.$this->id.'&CMD=displayImport">Click here to import CSV</a>'; 01188 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 01189 $theOutput.= $GLOBALS["SOBE"]->doc->section("Import",$out); 01190 break; 01191 case "mailerengine": 01192 if (t3lib_div::_GP("invokeMailerEngine")) { 01193 $out="<strong>Log:</strong><BR><BR><font color=#666666>".nl2br($this->invokeMEngine())."</font>"; 01194 $theOutput.= $GLOBALS["SOBE"]->doc->section("Mailer Engine Invoked!",$out); 01195 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 01196 } 01197 01198 // Display mailer engine status 01199 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 01200 'uid,pid,subject,scheduled,scheduled_begin,scheduled_end', 01201 'sys_dmail', 01202 'pid='.intval($this->id).' AND scheduled>0'.t3lib_BEfunc::deleteClause('sys_dmail'), 01203 '', 01204 $GLOBALS['TYPO3_DB']->stripOrderBy($TCA['sys_dmail']['ctrl']['default_sortby']) 01205 ); 01206 $out=""; 01207 $out.='<tr> 01208 <td class="bgColor5">'.fw(" ").'</td> 01209 <td class="bgColor5"><b>'.fw("Subject ").'</b></td> 01210 <td class="bgColor5"><b>'.fw("Scheduled ").'</b></td> 01211 <td class="bgColor5"><b>'.fw("Delivery begun ").'</b></td> 01212 <td class="bgColor5"><b>'.fw("Delivery ended ").'</b></td> 01213 <td class="bgColor5"><b>'.fw(" # sent ").'</b></td> 01214 </tr>'; 01215 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01216 $countres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=0'); 01217 list($count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($countres); 01218 01219 $out.='<tr> 01220 <td><img src="'.$GLOBALS["BACK_PATH"].'gfx/i/mail.gif" width=18 height=16 border=0 align="top"></td> 01221 <td>'.$this->linkDMail_record(fw(t3lib_div::fixed_lgd($row["subject"],30)." "),$row["uid"]).'</td> 01222 <td>'.fw(t3lib_BEfunc::datetime($row["scheduled"])." ").'</td> 01223 <td>'.fw(($row["scheduled_begin"]?t3lib_BEfunc::datetime($row["scheduled_begin"]):"")." ").'</td> 01224 <td>'.fw(($row["scheduled_end"]?t3lib_BEfunc::datetime($row["scheduled_end"]):"")." ").'</td> 01225 <td align=right>'.fw($count?$count:" ").'</td> 01226 </tr>'; 01227 01228 } 01229 $out='<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>'; 01230 $out.='<BR>Current time: '.t3lib_BEfunc::datetime(time())."<BR>"; 01231 01232 $theOutput.= $GLOBALS["SOBE"]->doc->section("Mail Engine Status",$out,0,1); 01233 // Invoke engine 01234 01235 $out='If TYPO3 is not configured to automatically invoke the Mailer Engine, you can invoke it by clicking here:<BR><BR> <a href="index.php?id='.$this->id.'&invokeMailerEngine=1"><strong>Invoke Mailer Engine</strong></a>'; 01236 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 01237 $theOutput.= $GLOBALS["SOBE"]->doc->section("Manually Invoke Engine",$out); 01238 break; 01239 case "quick": 01240 $theOutput.= $this->cmd_quickmail(); 01241 break; 01242 case "conf": 01243 $configArray = array( 01244 "spacer0" => "Set default values for Direct Mails:", 01245 "from_email" => array("string", "'From' email", "Enter the sender email address. (Required)"), 01246 "from_name" => array("string", "'From' name", "Enter the sender name. (Required)"), 01247 "replyto_email" => array("string", "'Reply To' email", "Enter the email address to which replys are sent. If none, the 'From' email is used. (Optional)"), 01248 "replyto_name" => array("string", "'Reply To' name", "Enter the name of the 'Reply To' email address. If none, the 'From' name is used. (Optional)"), 01249 "return_path" => array("string", "'Return Path'", "Enter the return path email address here. This is the address to which non-deliverable mails will be returned to. If you put in the marker ###XID### it'll be substituted with the unique id of the mail/recipient."), 01250 "organisation" => array("string", "Organisation name", "(Optional)"), 01251 "spacer1" => "", 01252 "sendOptions" => array("select", "Default Format options", "Select the format of the mail content. If in doubt, set it to 'Plain and HTML'. The recipients are normally able to select their preferences anyway.", array(0=>"",1=>"Plain text only",2=>"HTML only",3=>"Plain and HTML")), 01253 "HTMLParams" => array("short", "HTML parameters", "Enter the additional URL parameters used to fetch the HTML content. If in doubt, leave it blank."), 01254 "plainParams" => array("short", "Plain Text parameters", "Enter the additional URL parameters used to fetch the plain text content. If in doubt, set it to '&type=99' which is standard."), 01255 01256 "long_link_rdct_url" => array("string", "Long link RDCT url", "If you enter a http://../ url here it should point to the index.php script of typo3 without any query-string. Then the parameter ?RDCT=[md5hash] will be appended and the whole url used as substitute for long urls in plain text mails. This configuration determines how QuickMails are handled and further sets the default setting for DirectMails."), 01257 "long_link_mode" => array("check", "Not only links longer than 76 chars but ALL links", "Option for the RDCT-url feature above."), 01258 "quick_mail_encoding" => array("select", "Encoding for quick mails", "Select the encoding you want to sending of quick-mails.", array(0=>"","base64"=>"base64","quoted-printable"=>"quoted-printable","8bit"=>"8bit")), 01259 "spacer2" => "Configure technical options", 01260 "enablePlain" => array("check", "Allow Plain Text emails", "Set this if you want to allow plain text emails to be fetched. If in doubt, check this option."), 01261 "enableHTML" => array("check", "Allow HTML emails", "Set this if you want to allow HTML emails to be fetched. If in doubt, check this option."), 01262 "http_username" => array("short", "HTTP username", "If the mail content is protected by a HTTP authentication, enter the username here. The username and password is used to fetch the mail content. They are NOT sent in the mail!<BR>If you don't enter a username and password and the newsletter pages happens to be protected, an error will occur and no mail content is fetched."), 01263 "http_password" => array("short", "HTTP password", "... and enter the password here."), 01264 "test_tt_address_uids" => array("short", "List of UID numbers of test-recipients", "Before sending mails you should test the mail content by sending testmails to one or more test recipients. The available recipients for testing are determined by the list of UID numbers, you enter here. So first, find out the UID-numbers of the recipients you wish to use for testing, then enter them here in a comma-separated list."), 01265 "test_dmail_group_uids" => array("short", "List of UID numbers of test dmail_groups", "Alternatively to sending test-mails to individuals, you can choose to send to a whole group. List the group ids available for this action here:"), 01266 "spacer3" => "Available categories" 01267 ); 01268 for ($a=0;$a<9;$a++) { 01269 $configArray["categories.".$a] = array("short", "Category ".$a, ""); 01270 } 01271 $configArray["spacer4"] = array("comment","","(You can use categories from 0-30 inclusive. However this interface shows only 10 categories for your convenience.)"); 01272 01273 $theOutput.= $GLOBALS["SOBE"]->doc->section("Configure direct mail module",t3lib_BEfunc::makeConfigForm($configArray,$this->implodedParams,"pageTS"),0,1); 01274 break; 01275 case "help": 01276 // if ($GLOBALS["BE_USER"]->uc["helpText"]) { 01277 // Make this a link to the online documentation instead!!! 01278 // How this works. 01279 $theOutput.= $GLOBALS["SOBE"]->doc->section("How this works...",nl2br(trim(" 01280 In this module you can create newsletters (pages), which can be emailed as 'direct mails' to people on a subscription list. 01281 01282 To create a direct mail, you must follow these steps: 01283 <B>1)</B> Select 'Newsletter' in the menu above. 01284 <B>2)</B> Create a new 'newsletter'. Put content in that newsletter, save it, preview it - exactly as you're used to with regular pages in TYPO3. Actually a 'newsletter' in this context is simply a TYPO3 page destined for emailing! 01285 <B>3)</B> Click your new newsletter in the list. Now you can see information about that page, categorize the content elements. 01286 <B>4)</B> When your newsletter is ready to be distributed, click the link 'Create new direct mail based on this page' and a new direct mail based on your newsletter is created. 01287 <B>5)</B> The first thing to do with your new 'Direct Mail' is to fetch the mail content. This process reads the content from the page and compiles a mail out of it. 01288 <B>6)</B> Send a test. You should definitely send a testmail to yourself before mailing to your subscribers. Doing so, you can make sure that the mail and all links in it are correctly set up. Be aware if there are links to local network URLs. Those will not be accessible to the people receiving your newsletter! 01289 <B>7)</B> Initialize distribution if everything is OK. 01290 01291 <B>The difference of a newsletter and a direct mail</B> 01292 A 'newsletter' is basically a regular TYPO3 page which resides here in the direct mail module. You can view the page in a browser and the point is that this page is finally send as a direct mail. 01293 A 'direct mail' is a record that contains a compiled version of either a newsletter page or alternatively the content of an external url. In addition the direct mail contains information like the mail subject, any attachments, priority settings, reply addresses and all that. For each direct mail a log is kept of who has received the direct mail and if they responded to it. 01294 01295 01296 <B>Data fields in direct mails:</B> 01297 You can insert personalized data in the mails by inserting these markers: 01298 ###USER_uid### (the unique id of the recipient) 01299 ###USER_name### (full name) 01300 ###USER_firstname### (first name calculated) 01301 ###USER_title### 01302 ###USER_email### 01303 ###USER_phone### 01304 ###USER_www### 01305 ###USER_address### 01306 ###USER_company### 01307 ###USER_city### 01308 ###USER_zip### 01309 ###USER_country### 01310 ###USER_fax### 01311 01312 ###SYS_TABLE_NAME### 01313 ###SYS_MAIL_ID### 01314 ###SYS_AUTHCODE### 01315 01316 (In addition ###USER_NAME### and ###USER_FIRSTNAME### will insert uppercase versions of the equalents) 01317 ")),0,1); 01318 // } 01319 break; 01320 } 01321 return $theOutput; 01322 } 01323 function editLink($table,$uid) { 01324 $params = '&edit['.$table.']['.$uid.']=edit'; 01325 $str = '<a href="#" onClick="'.t3lib_BEfunc::editOnClick($params,$GLOBALS["BACK_PATH"],"").'"><img src="'.$GLOBALS["BACK_PATH"].'gfx/edit2.gif" width="11" height="12" hspace=3 vspace=2 border="0" align=top></a>'; 01326 return $str; 01327 } 01328 function invokeMEngine() { 01329 $htmlmail = t3lib_div::makeInstance("t3lib_dmailer"); 01330 $htmlmail->start(); 01331 $htmlmail->runcron(); 01332 return implode(chr(10),$htmlmail->logArray); 01333 } 01334 function updatePageTS() { 01335 $pageTS = t3lib_div::_GP("pageTS"); 01336 if (is_array($pageTS)) { 01337 t3lib_BEfunc::updatePagesTSconfig($this->id,$pageTS,$this->TSconfPrefix); 01338 // debug(t3lib_div::getIndpEnv("REQUEST_URI")); 01339 header("Location: ".t3lib_div::locationHeaderUrl(t3lib_div::getIndpEnv("REQUEST_URI"))); 01340 } 01341 } 01342 function addUserPass($url) { 01343 $user = $this->params["http_username"]; 01344 $pass = $this->params["http_password"]; 01345 01346 if ($user && $pass && substr($url,0,7)=="http://") { 01347 $url = "http://".$user.":".$pass."@".substr($url,7); 01348 } 01349 return $url; 01350 } 01351 function cmd_fetch($row) { 01352 // Compile the mail 01353 $htmlmail = t3lib_div::makeInstance("t3lib_dmailer"); 01354 $htmlmail->jumperURL_prefix = $this->urlbase."?id=".$row["page"]."&rid=###SYS_TABLE_NAME###_###USER_uid###&mid=###SYS_MAIL_ID###&jumpurl="; 01355 $htmlmail->jumperURL_useId=1; 01356 $htmlmail->start(); 01357 $htmlmail->useBase64(); 01358 $htmlmail->http_username = $this->params["http_username"]; 01359 $htmlmail->http_password = $this->params["http_password"]; 01360 01361 if ($this->url_plain) { 01362 $htmlmail->addPlain(t3lib_div::getURL($this->addUserPass($this->url_plain))); 01363 } 01364 if ($this->url_html) { 01365 $htmlmail->addHTML($this->url_html); // Username and password is added in htmlmail object 01366 } 01367 // debug($htmlmail->theParts); 01368 // debug(base64_decode($htmlmail->theParts["plain"]["content"])); 01369 01370 $attachmentArr = t3lib_div::trimExplode(",", $row["attachment"],1); 01371 if (count($attachmentArr)) { 01372 t3lib_div::loadTCA("sys_dmail"); 01373 $upath = $GLOBALS["TCA"]["sys_dmail"]["columns"]["attachment"]["config"]["uploadfolder"]; 01374 while(list(,$theName)=each($attachmentArr)) { 01375 $theFile = PATH_site.$upath."/".$theName; 01376 if (@is_file($theFile)) { 01377 $htmlmail->addAttachment($theFile, $theName); 01378 } 01379 } 01380 } 01381 01382 // Update the record: 01383 $htmlmail->theParts["messageid"] = $htmlmail->messageid; 01384 $mailContent = serialize($htmlmail->theParts); 01385 01386 $updateFields = array( 01387 'issent' => 0, 01388 'mailContent' => $mailContent, 01389 'renderedSize' => strlen($mailContent) 01390 ); 01391 01392 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_dmail', 'uid='.intval($this->sys_dmail_uid), $updateFields); 01393 01394 // Read again: 01395 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_dmail', 'pid='.intval($this->id).' AND uid='.intval($this->sys_dmail_uid).t3lib_BEfunc::deleteClause('sys_dmail')); 01396 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 01397 return $theOutput; 01398 } 01399 function cmd_prefetch($row) { 01400 if ($row["sendOptions"]) { 01401 $msg = "You're about to read the url with the mail-content from these URL's:<BR><BR>"; 01402 01403 if ($this->url_plain) { 01404 $msg.= '<B>PLAIN:</b> <a href="'.$this->url_plain.'" target="testing_window">'.htmlspecialchars($this->url_plain).'</a><BR>'; 01405 } 01406 if ($this->url_html) { 01407 $msg.= '<B>HTML:</b> <a href="'.$this->url_html.'" target="testing_window">'.htmlspecialchars($this->url_html).'</a><BR><BR>'; 01408 } 01409 01410 $msg.= 'This operation may take a while. Therefore be patient.<BR><BR> 01411 Be aware if the URL is password protected, you must set up the http username and password in the "Configuration" section. Else you will get an error.<BR><BR>'; 01412 $msg.= '<input type="Submit" value="Read URL" onClick="jumpToUrlD(\'index.php?id='.$this->id.'&sys_dmail_uid='.$this->sys_dmail_uid.'&CMD=fetch\'); return false;"> '; 01413 $msg.= $this->back; 01414 $theOutput.= $GLOBALS["SOBE"]->doc->section("Fetching the mail content",fw($msg)); 01415 } else { 01416 $theOutput.= $GLOBALS["SOBE"]->doc->section("ERROR",fw("You must choose to send either HTML, plaintext or both. Nothing is selected at this time!<br><br>".$this->back)); 01417 } 01418 $this->noView=1; 01419 return $theOutput; 01420 } 01421 function cmd_testmail($row) { 01422 if ($this->params["test_tt_address_uids"]) { 01423 $intList = implode(t3lib_div::intExplode(",",$this->params["test_tt_address_uids"]),","); 01424 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tt_address.*', 'tt_address,pages', 'pages.uid=tt_address.pid AND tt_address.uid IN ('.$intList.') AND '.$this->perms_clause.t3lib_BEfunc::deleteClause('tt_address').t3lib_BEfunc::deleteClause('pages')); 01425 $msg = "Select a recipient of the testmail. The mail will be generated based on the profile of the recipient, you select.<BR><BR>"; 01426 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01427 $msg.='<a href="index.php?id='.$this->id.'&CMD=displayUserInfo&table=tt_address&uid='.$row["uid"].'"><img src="'.$GLOBALS["BACK_PATH"].'gfx/zoom2.gif" width=12 height=12 hspace=5 border=0 title="Edit" align="top"></a><a href="index.php?id='.$this->id.'&sys_dmail_uid='.$this->sys_dmail_uid.'&CMD=send_mail_test&tt_address_uid='.$row["uid"].'"><img src="'.$GLOBALS["BACK_PATH"].t3lib_iconWorks::getIcon("tt_address", $row).'" width=18 height=16 align=top border=0>'.htmlspecialchars($row["name"]." <".$row["email"].">".($row["module_sys_dmail_html"]?" html":""))."</a><BR>"; 01428 } 01429 $theOutput.= $GLOBALS["SOBE"]->doc->section("Testmail - Individuals",fw($msg)); 01430 $theOutput.= $GLOBALS["SOBE"]->doc->divider(20); 01431 } 01432 01433 01434 if ($this->params["test_dmail_group_uids"]) { 01435 $intList = implode(t3lib_div::intExplode(",",$this->params["test_dmail_group_uids"]),","); 01436 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_dmail_group.*', 'sys_dmail_group,pages', 'pages.uid=sys_dmail_group.pid AND sys_dmail_group.uid IN ('.$intList.') AND '.$this->perms_clause.t3lib_BEfunc::deleteClause('sys_dmail_group').t3lib_BEfunc::deleteClause('pages')); 01437 $msg = "Select a recipient mail group for the testmail. The mails will be generated based on the profiles of the recipients in that group.<BR><BR>"; 01438 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01439 $msg.='<a href="index.php?id='.$this->id.'&sys_dmail_uid='.$this->sys_dmail_uid.'&CMD=send_mail_test&sys_dmail_group_uid='.$row["uid"].'"><img src="'.$GLOBALS["BACK_PATH"].t3lib_iconWorks::getIcon("sys_dmail_group", $row).'" width=18 height=16 align=top border=0>'.htmlspecialchars($row["title"])."</a><BR>"; 01440 // Members: 01441 $result = $this->cmd_compileMailGroup(intval($row["uid"])); 01442 $msg.='<table border=0> 01443 <tr> 01444 <td><img src=clear.gif width=50 height=1></td> 01445 <td>'.$this->cmd_displayMailGroup_test($result).'</td> 01446 </tr> 01447 </table>'; 01448 } 01449 $theOutput.= $GLOBALS["SOBE"]->doc->section("Testmail - Direct Mail Group",fw($msg)); 01450 $theOutput.= $GLOBALS["SOBE"]->doc->divider(20); 01451 } 01452 01453 01454 $msg=""; 01455 $msg.= 'A simple testmail includes all mail elements regardless of category. But any USER_fields are not substituted with data.<BR>Enter an email-address for the testmail:<BR><BR>'; 01456 $msg.= '<input'.$GLOBALS["TBE_TEMPLATE"]->formWidth().' type="Text" name="SET[test_email]" value="'.$GLOBALS["SOBE"]->MOD_SETTINGS["dmail_test_email"].'"><BR><BR>'; 01457 $msg.= '<input type="hidden" name="id" value="'.$this->id.'">'; 01458 $msg.= '<input type="hidden" name="sys_dmail_uid" value="'.$this->sys_dmail_uid.'">'; 01459 $msg.= '<input type="hidden" name="CMD" value="send_mail_test">'; 01460 $msg.= '<input type="Submit" name="mailingMode_simple" value="Send">'; 01461 01462 $theOutput.= $GLOBALS["SOBE"]->doc->section("Testmail - simple",fw($msg)); 01463 01464 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(20); 01465 $theOutput.= $GLOBALS["SOBE"]->doc->section("",$this->back); 01466 01467 $this->noView=1; 01468 return $theOutput; 01469 } 01470 01471 function cmd_finalmail($row) { 01472 global $TCA; 01473 // Mail groups 01474 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,pid,title', 'sys_dmail_group', 'pid='.intval($this->id).t3lib_BEfunc::deleteClause('sys_dmail_group'), '', $GLOBALS['TYPO3_DB']->stripOrderBy($TCA['sys_dmail_group']['ctrl']['default_sortby'])); 01475 $opt = array(); 01476 $opt[] = '<option></option>'; 01477 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01478 $opt[] = '<option value="'.$row["uid"].'">'.htmlspecialchars($row["title"]).'</option>'; 01479 } 01480 $select = '<select name="mailgroup_uid">'.implode(chr(10),$opt).'</select>'; 01481 01482 // Set up form: 01483 $msg=""; 01484 $msg.= '<input type="hidden" name="id" value="'.$this->id.'">'; 01485 $msg.= '<input type="hidden" name="sys_dmail_uid" value="'.$this->sys_dmail_uid.'">'; 01486 $msg.= '<input type="hidden" name="CMD" value="send_mail_final">'; 01487 $msg.= $select."<BR>"; 01488 $msg.='Distribution time (hh:mm dd-mm-yy):<BR><input type="text" name="send_mail_datetime_hr'.'" onChange="typo3FormFieldGet(\'send_mail_datetime\', \'datetime\', \'\', 0,0);"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).'><input type="hidden" value="'.time().'" name="send_mail_datetime"><BR>'; 01489 $this->extJSCODE.='typo3FormFieldSet("send_mail_datetime", "datetime", "", 0,0);'; 01490 $msg.= '<input type="Submit" name="mailingMode_mailGroup" value="Send to all subscribers in mail group">'; 01491 01492 01493 01494 $theOutput.= $GLOBALS["SOBE"]->doc->section("Select a Mail Group",fw($msg)); 01495 $theOutput.= $GLOBALS["SOBE"]->doc->divider(20); 01496 01497 01498 $msg=""; 01499 $msg.= 'Enter the email-addresses for the recipients. Separate the addresses with linebreak or comma ",":<BR><BR>'; 01500 $msg.= '<textarea'.$GLOBALS["TBE_TEMPLATE"]->formWidthText().' rows=30 name="email"></textarea><BR><BR>'; 01501 $msg.= '<input type="hidden" name="id" value="'.$this->id.'">'; 01502 $msg.= '<input type="hidden" name="sys_dmail_uid" value="'.$this->sys_dmail_uid.'">'; 01503 $msg.= '<input type="hidden" name="CMD" value="send_mail_final">'; 01504 $msg.= '<input type="Submit" name="mailingMode_simple" value="Send">'; 01505 01506 $msg.=$this->JSbottom(); 01507 01508 $theOutput.= $GLOBALS["SOBE"]->doc->section("Send mail - list of emails",fw($msg)); 01509 $this->noView=1; 01510 return $theOutput; 01511 } 01512 function getUniqueEmailsFromGroup($mailgroup_uid) { 01513 $result = $this->cmd_compileMailGroup(intval($mailgroup_uid)); 01514 $idLists = $result["queryInfo"]["id_lists"]; 01515 $emailArr = array(); 01516 $emailArr = $this->addMailAddresses($idLists,"tt_address",$emailArr); 01517 $emailArr = $this->addMailAddresses($idLists,"fe_users",$emailArr); 01518 $emailArr = $this->addMailAddresses($idLists,"PLAINLIST",$emailArr); 01519 $emailArr = $this->addMailAddresses($idLists,$this->userTable,$emailArr); 01520 $emailArr = array_unique($emailArr); 01521 return $emailArr; 01522 } 01523 function cmd_quickmail() { 01524 global $TCA,$BE_USER; 01525 $theOutput=""; 01526 $whichMode=""; 01527 01528 // Check if send mail: 01529 if (t3lib_div::_GP("quick_mail_send")) { 01530 $mailgroup_uid = t3lib_div::_GP("mailgroup_uid"); 01531 $senderName = t3lib_div::_GP("senderName"); 01532 $senderEmail = t3lib_div::_GP("senderEmail"); 01533 $subject = t3lib_div::_GP("subject"); 01534 $message = t3lib_div::_GP("message"); 01535 $sendMode = t3lib_div::_GP("sendMode"); 01536 $breakLines = t3lib_div::_GP("breakLines"); 01537 if ($mailgroup_uid && $senderName && $senderEmail && $subject && $message) { 01538 01539 $emailArr = $this->getUniqueEmailsFromGroup($mailgroup_uid); 01540 01541 if (count($emailArr)) { 01542 if (trim($this->params["long_link_rdct_url"])) { 01543 #debug(array($this->params["long_link_rdct_url"],$this->params["long_link_mode"]?"all":"76")); 01544 $message = t3lib_div::substUrlsInPlainText($message,$this->params["long_link_mode"]?"all":"76",trim($this->params["long_link_rdct_url"])); 01545 } 01546 if ($breakLines) { 01547 $message = t3lib_div::breakTextForEmail($message); 01548 } 01549 01550 $headers=array(); 01551 $headers[]="From: ".$senderName." <".$senderEmail.">"; 01552 $headers[]="Return-path: ".$senderName." <".$senderEmail.">"; 01553 01554 if ($sendMode=="CC") { 01555 $headers[]="Cc: ".implode(",",$emailArr); 01556 t3lib_div::plainMailEncoded($senderEmail,$subject,$message,implode(chr(13).chr(10),$headers),$this->params["quick_mail_encoding"]); 01557 $whichMode="One mail to all recipients in Carbon Copy (Cc)"; 01558 } 01559 if ($sendMode=="BCC") { 01560 $headers[]="Bcc: ".implode(",",$emailArr); 01561 t3lib_div::plainMailEncoded($senderEmail,$subject,$message,implode(chr(13).chr(10),$headers),$this->params["quick_mail_encoding"]); 01562 $whichMode="One mail to all recipients in Blind Carbon Copy (Bcc)"; 01563 } 01564 if ($sendMode=="1-1") { 01565 reset($emailArr); 01566 while(list(,$email)=each($emailArr)) { 01567 t3lib_div::plainMailEncoded($email,$subject,$message,implode(chr(13).chr(10),$headers),$this->params["quick_mail_encoding"]); 01568 } 01569 $whichMode="Many mails, one for each recipient"; 01570 } 01571 $msg="<strong>Sent to:</strong>"; 01572 $msg.='<table border=0> 01573 <tr> 01574 <td><img src=clear.gif width=50 height=1></td> 01575 <td><em>'.implode(", ",$emailArr).'</em></td> 01576 </tr> 01577 </table> 01578 <BR> 01579 <strong>Copy to:</strong> '.$senderEmail.'<BR> 01580 <strong>Mode:</strong> '.$whichMode; 01581 } else { 01582 $msg="No recipients"; 01583 } 01584 $theOutput.= $GLOBALS["SOBE"]->doc->section("Mails are sent",$msg,0,1); 01585 } else { 01586 $theOutput.= $GLOBALS["SOBE"]->doc->section("Error","You didn't fill in all the fields correctly!",0,1); 01587 } 01588 } 01589 01590 if (!$whichMode) { 01591 // Mail groups 01592 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,pid,title', 'sys_dmail_group', 'pid='.intval($this->id).t3lib_BEfunc::deleteClause('sys_dmail_group'), '', $GLOBALS['TYPO3_DB']->stripOrderBy($TCA['sys_dmail_group']['ctrl']['default_sortby'])); 01593 $opt = array(); 01594 $opt[] = '<option></option>'; 01595 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01596 $opt[] = '<option value="'.$row["uid"].'"'.($mailgroup_uid==$row["uid"]?" selected":"").'>'.htmlspecialchars($row["title"]).'</option>'; 01597 } 01598 $select = '<select name="mailgroup_uid">'.implode(chr(10),$opt).'</select>'; 01599 01600 $selectMode = '<select name="sendMode"> 01601 <option value="BCC"'.($sendMode=="BCC"?" selected":"").'>One mail to all recipients in Blind Carbon Copy (Bcc)</option> 01602 <option value="CC"'.($sendMode=="CC"?" selected":"").'>One mail to all recipients in Carbon Copy (Cc)</option> 01603 <option value="1-1"'.($sendMode=="1-1"?" selected":"").'>Many mails, one for each recipient</option> 01604 </select>'; 01605 // Set up form: 01606 $msg=""; 01607 $msg.= '<input type="hidden" name="id" value="'.$this->id.'">'; 01608 $msg.= $select.$selectMode."<BR>"; 01609 if ($mailgroup_uid) { 01610 $msg.='Recipients:<BR><em>'.implode(", ",$this->getUniqueEmailsFromGroup($mailgroup_uid)).'</em><BR><BR>'; 01611 } 01612 $msg.= 'Sender Name:<BR><input type="text" name="senderName" value="'.($senderName?$senderName:$BE_USER->user["realName"]).'"'.$GLOBALS["SOBE"]->doc->formWidth().'><BR>'; 01613 $msg.= 'Sender Email:<BR><input type="text" name="senderEmail" value="'.($senderEmail?$senderEmail:$BE_USER->user["email"]).'"'.$GLOBALS["SOBE"]->doc->formWidth().'><BR>'; 01614 $msg.= 'Subject:<BR><input type="text" name="subject" value="'.$subject.'"'.$GLOBALS["SOBE"]->doc->formWidth().'><BR>'; 01615 $msg.= 'Message:<BR><textarea rows="20" name="message"'.$GLOBALS["SOBE"]->doc->formWidthText().'>'.t3lib_div::formatForTextarea($message).'</textarea><BR>'; 01616 $msg.= 'Break lines to 76 char: <input type="checkbox" name="breakLines" value="1"'.($breakLines?" checked":"").'><BR><BR>'; 01617 01618 $msg.= '<input type="Submit" name="quick_mail_send" value="Send message to all members of group immediately">'; 01619 $msg.= '<BR><input type="Submit" name="cancel" value="Cancel">'; 01620 01621 $theOutput.= $GLOBALS["SOBE"]->doc->section("Quick-Mail",$msg,0,1); 01622 } 01623 return $theOutput; 01624 } 01625 function sendTestMailToTable($idLists,$table,$htmlmail) { 01626 $sentFlag=0; 01627 if (is_array($idLists[$table])) { 01628 if ($table!="PLAINLIST") { 01629 $recs=$this->fetchRecordsListValues($idLists[$table],$table,"*"); 01630 } else { 01631 $recs = $idLists["PLAINLIST"]; 01632 } 01633 reset($recs); 01634 while(list($k,$rec)=each($recs)) { 01635 $recipRow = t3lib_dmailer::convertFields($rec); 01636 // debug($recipRow); 01637 $kc = substr($table,0,1); 01638 $htmlmail->dmailer_sendAdvanced($recipRow,$kc=="p"?"P":$kc); 01639 $sentFlag++; 01640 } 01641 } 01642 return $sentFlag; 01643 } 01644 function addMailAddresses($idLists,$table,$arr) { 01645 if (is_array($idLists[$table])) { 01646 if ($table!="PLAINLIST") { 01647 $recs=$this->fetchRecordsListValues($idLists[$table],$table,"*"); 01648 } else { 01649 $recs = $idLists["PLAINLIST"]; 01650 } 01651 reset($recs); 01652 while(list($k,$rec)=each($recs)) { 01653 $arr[]=$rec["email"]; 01654 } 01655 } 01656 return $arr; 01657 } 01658 function cmd_send_mail($row) { 01659 // Preparing mailer 01660 $htmlmail = t3lib_div::makeInstance("t3lib_dmailer"); 01661 $htmlmail->start(); 01662 $htmlmail->dmailer_prepare($row); // ,$this->params 01663 01664 $sentFlag=false; 01665 if (t3lib_div::_GP("mailingMode_simple")) { 01666 // Fixing addresses: 01667 $addresses = split(chr(10)."|,|;",t3lib_div::_GP("email")); 01668 while(list($key,$val)=each($addresses)) { 01669 $addresses[$key]=trim($val); 01670 if (!strstr($addresses[$key],"@")) { 01671 unset($addresses[$key]); 01672 } 01673 } 01674 $hash = array_flip($addresses); 01675 $addresses = array_keys($hash); 01676 $addressList = implode($addresses,","); 01677 01678 if ($addressList) { 01679 // Sending the same mail to lots of recipients 01680 $htmlmail->dmailer_sendSimple($addressList); 01681 $sentFlag=true; 01682 $theOutput.= $GLOBALS["SOBE"]->doc->section("Sending mail",fw("The mail was send.<BR><BR>Recipients:<BR>".$addressList."<BR><BR>".$this->back)); 01683 $this->noView=1; 01684 } 01685 } else { // extended, personalized emails. 01686 if ($this->CMD=="send_mail_test") { 01687 if (t3lib_div::_GP("tt_address_uid")) { 01688 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tt_address.*', 'tt_address,pages', 'pages.uid=tt_address.pid AND tt_address.uid='.intval(t3lib_div::_GP('tt_address_uid')).' AND '.$this->perms_clause.t3lib_BEfunc::deleteClause('tt_address').t3lib_BEfunc::deleteClause('pages')); 01689 if ($recipRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01690 $recipRow = t3lib_dmailer::convertFields($recipRow); 01691 $htmlmail->dmailer_sendAdvanced($recipRow,"t"); 01692 $sentFlag=true; 01693 $theOutput.= $GLOBALS["SOBE"]->doc->section("Sending mail",fw(sprintf("The mail was send to <strong>%s</strong>.<BR><BR>".$this->back, $recipRow["name"].htmlspecialchars(" <".$recipRow["email"].">")))); 01694 $this->noView=1; 01695 } 01696 } elseif (t3lib_div::_GP("sys_dmail_group_uid")) { 01697 $result = $this->cmd_compileMailGroup(t3lib_div::_GP("sys_dmail_group_uid")); 01698 01699 $idLists = $result["queryInfo"]["id_lists"]; 01700 $sendFlag=0; 01701 $sendFlag+=$this->sendTestMailToTable($idLists,"tt_address",$htmlmail); 01702 $sendFlag+=$this->sendTestMailToTable($idLists,"fe_users",$htmlmail); 01703 $sendFlag+=$this->sendTestMailToTable($idLists,"PLAINLIST",$htmlmail); 01704 $sendFlag+=$this->sendTestMailToTable($idLists,$this->userTable,$htmlmail); 01705 // debug($sendFlag); 01706 01707 if ($sendFlag) { 01708 $theOutput.= $GLOBALS["SOBE"]->doc->section("Sending mail",fw(sprintf("The mail was send to <strong>%s</strong> recipients.<BR><BR>".$this->back, $sendFlag))); 01709 $this->noView=1; 01710 } 01711 } 01712 } else { 01713 01714 01715 $mailgroup_uid = t3lib_div::_GP("mailgroup_uid"); 01716 if (t3lib_div::_GP("mailingMode_mailGroup") && $this->sys_dmail_uid && intval($mailgroup_uid)) { 01717 // Update the record: 01718 $result = $this->cmd_compileMailGroup(intval($mailgroup_uid)); 01719 $query_info=$result["queryInfo"]; 01720 // debug($query_info); 01721 01722 /* $query_info = array(); 01723 $query_info["tt_address"] = "tt_address.pid=".$this->id; 01724 $query_info["fe_users"] = "fe_users.pid=".$this->id; 01725 */ 01726 $distributionTime = intval(t3lib_div::_GP("send_mail_datetime")); 01727 $distributionTime = $distributionTime<time() ? time() : $distributionTime; 01728 01729 $updateFields = array( 01730 'scheduled' => $distributionTime, 01731 'query_info' => serialize($query_info) 01732 ); 01733 01734 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_dmail', 'uid='.intval($this->sys_dmail_uid), $updateFields); 01735 01736 $sentFlag=true; 01737 $theOutput.= $GLOBALS["SOBE"]->doc->section("Mail scheduled for distribution",fw('The mail was scheduled for distribution at '.t3lib_BEfunc::datetime($distributionTime).'.<BR><BR>'.$this->back)); 01738 $this->noView=1; 01739 } 01740 // Here the correct address-records are selected and ... 01741 } 01742 } 01743 01744 // Setting flags: 01745 if ($sentFlag && $this->CMD=="send_mail_final") { 01746 // Update the record: 01747 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_dmail', 'uid='.intval($this->sys_dmail_uid), array('issent' => 1)); 01748 01749 // Read again: 01750 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_dmail', 'pid='.intval($this->id).' AND uid='.intval($this->sys_dmail_uid).t3lib_BEfunc::deleteClause('sys_dmail')); 01751 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 01752 } 01753 return $theOutput; 01754 } 01755 function showWithPercent($pieces,$total) { 01756 $total = intval($total); 01757 $str = $pieces; 01758 if ($total) { 01759 $str.= " / ".number_format(($pieces/$total*100),2)."%"; 01760 } 01761 return $str; 01762 } 01763 function formatTable($tableLines,$cellParams,$header,$cellcmd=array(),$tableParams='border=0 cellpadding=2 cellspacing=1') { 01764 reset($tableLines); 01765 $cols = count(current($tableLines)); 01766 01767 reset($tableLines); 01768 $lines=array(); 01769 $first=$header?1:0; 01770 while(list(,$r)=each($tableLines)) { 01771 $rowA=array(); 01772 for($k=0;$k<$cols;$k++) { 01773 $v=$r[$k]; 01774 $v = $v ? ($cellcmd[$k]?$v:htmlspecialchars($v)) : " "; 01775 if ($first) $v='<B>'.$v.'</B>'; 01776 $rowA[]='<td'.($cellParams[$k]?" ".$cellParams[$k]:"").'>'.$v.'</td>'; 01777 } 01778 $lines[]='<tr class="'.($first?'bgColor5':'bgColor4').'">'.implode("",$rowA).'</tr>'; 01779 $first=0; 01780 } 01781 $table = '<table '.$tableParams.'>'.implode("",$lines).'</table>'; 01782 return $table; 01783 } 01784 function cmd_stats($row) { 01785 if (t3lib_div::_GP("recalcCache")) { 01786 $this->makeStatTempTableContent($row); 01787 } 01788 $thisurl = "index.php?id=".$this->id."&sys_dmail_uid=".$row["uid"]."&CMD=".$this->CMD."&recalcCache=1"; 01789 01790 01791 $output.=t3lib_iconWorks::getIconImage("sys_dmail",$row,$GLOBALS["BACK_PATH"],'align="top"').$row["subject"]."<BR>"; 01792 01793 // ***************************** 01794 // Mail responses, general: 01795 // ***************************** 01796 $queryArray = array('response_type,count(*) as counter', 'sys_dmail_maillog', 'mid='.intval($row['uid']), 'response_type'); 01797 $table = $this->getQueryRows($queryArray, 'response_type'); 01798 01799 // Plaintext/HTML 01800 $queryArray = array('html_sent,count(*) as counter', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=0', 'html_sent'); 01801 $table2 = $this->getQueryRows($queryArray, 'html_sent'); 01802 01803 // Unique responses, html 01804 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) as counter', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=1', 'rid,rtbl', 'counter'); 01805 $unique_html_responses = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 01806 01807 // Unique responses, Plain 01808 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) as counter', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=2', 'rid,rtbl', 'counter'); 01809 $unique_plain_responses = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 01810 01811 // Unique responses, pings 01812 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) as counter', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=-1', 'rid,rtbl', 'counter'); 01813 $unique_ping_responses = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 01814 01815 01816 $tblLines=array(); 01817 $tblLines[]=array("","Total:","HTML:","Plaintext:"); 01818 01819 $sent_total = intval($table["0"]["counter"]); 01820 $sent_html = intval($table2["3"]["counter"]+$table2["1"]["counter"]); 01821 $sent_plain = intval($table2["2"]["counter"]); 01822 $tblLines[]=array("Mails sent:",$sent_total,$sent_html,$sent_plain); 01823 $tblLines[]=array("Mails returned:",$this->showWithPercent($table["-127"]["counter"],$sent_total)); 01824 $tblLines[]=array("HTML mails viewed:","",$this->showWithPercent($unique_ping_responses,$sent_html)); 01825 $tblLines[]=array("Unique responses (link click):",$this->showWithPercent($unique_html_responses+$unique_plain_responses,$sent_total),$this->showWithPercent($unique_html_responses,$sent_html),$this->showWithPercent($unique_plain_responses,$sent_plain)); 01826 01827 $output.='<BR><strong>General information:</strong>'; 01828 $output.=$this->formatTable($tblLines,array("nowrap","nowrap align=right","nowrap align=right","nowrap align=right"),1); 01829 01830 01831 // ****************** 01832 // Links: 01833 // ****************** 01834 01835 // Most popular links, html: 01836 $queryArray = array('url_id,count(*) as counter', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=1', 'url_id', 'counter'); 01837 $htmlUrlsTable=$this->getQueryRows($queryArray,"url_id"); 01838 01839 // Most popular links, plain: 01840 $queryArray = array('url_id,count(*) as counter', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=2', 'url_id', 'counter'); 01841 $plainUrlsTable=$this->getQueryRows($queryArray,"url_id"); 01842 01843 // Find urls: 01844 $temp_unpackedMail = unserialize($row["mailContent"]); 01845 $urlArr=array(); 01846 $urlMd5Map=array(); 01847 if (is_array($temp_unpackedMail["html"]["hrefs"])) { 01848 reset($temp_unpackedMail["html"]["hrefs"]); 01849 while(list($k,$v)=each($temp_unpackedMail["html"]["hrefs"])) { 01850 $urlArr[$k]=$v["absRef"]; 01851 $urlMd5Map[md5($v["absRef"])]=$k; 01852 } 01853 } 01854 if (is_array($temp_unpackedMail["plain"]["link_ids"])) { 01855 reset($temp_unpackedMail["plain"]["link_ids"]); 01856 while(list($k,$v)=each($temp_unpackedMail["plain"]["link_ids"])) { 01857 $urlArr[intval(-$k)]=$v; 01858 } 01859 } 01860 // Traverse plain urls: 01861 reset($plainUrlsTable); 01862 $plainUrlsTable_mapped=array(); 01863 while(list($id,$c)=each($plainUrlsTable)) { 01864 $url = $urlArr[intval($id)]; 01865 if (isset($urlMd5Map[md5($url)])) { 01866 $plainUrlsTable_mapped[$urlMd5Map[md5($url)]]=$c; 01867 } else { 01868 $plainUrlsTable_mapped[$id]=$c; 01869 } 01870 } 01871 01872 // Traverse html urls: 01873 $urlCounter["html"]=array(); 01874 reset($htmlUrlsTable); 01875 while(list($id,$c)=each($htmlUrlsTable)) { 01876 $urlCounter["html"][$id]=$c["counter"]; 01877 } 01878 $urlCounter["total"]=$urlCounter["html"]; 01879 01880 // Traverse plain urls: 01881 $urlCounter["plain"]=array(); 01882 reset($plainUrlsTable_mapped); 01883 while(list($id,$c)=each($plainUrlsTable_mapped)) { 01884 $urlCounter["plain"][$id]=$c["counter"]; 01885 $urlCounter["total"][$id]+=$c["counter"]; 01886 } 01887 01888 $tblLines=array(); 01889 $tblLines[]=array("","Total:","HTML:","Plaintext:",""); 01890 $tblLines[]=array("Total responses (link click):",$this->showWithPercent($table["1"]["counter"]+$table["2"]["counter"],$sent_total),$this->showWithPercent($table["1"]["counter"],$sent_html),$this->showWithPercent($table["2"]["counter"],$sent_plain)); 01891 $tblLines[]=array("Unique responses (link click):",$this->showWithPercent($unique_html_responses+$unique_plain_responses,$sent_total),$this->showWithPercent($unique_html_responses,$sent_html),$this->showWithPercent($unique_plain_responses,$sent_plain)); 01892 $tblLines[]=array("Links clicked per respondent:", 01893 ($unique_html_responses+$unique_plain_responses ? number_format(($table["1"]["counter"]+$table["2"]["counter"])/($unique_html_responses+$unique_plain_responses),2):""), 01894 ($unique_html_responses ? number_format(($table["1"]["counter"])/($unique_html_responses),2):""), 01895 ($unique_plain_responses ? number_format(($table["2"]["counter"])/($unique_plain_responses),2):"") 01896 ); 01897 arsort($urlCounter["total"]); 01898 arsort($urlCounter["html"]); 01899 arsort($urlCounter["plain"]); 01900 /* $tblLines[]=array("Most popular link:","#".key($urlCounter["total"]),"#".key($urlCounter["html"]),"#".key($urlCounter["plain"])); 01901 end($urlCounter["total"]); 01902 end($urlCounter["html"]); 01903 end($urlCounter["plain"]); 01904 $tblLines[]=array("Least popular link:","#".key($urlCounter["total"]),"#".key($urlCounter["html"]),"#".key($urlCounter["plain"])); 01905 */ 01906 reset($urlCounter["total"]); 01907 while(list($id,$c)=each($urlCounter["total"])) { 01908 $uParts = parse_url($urlArr[intval($id)]); 01909 $urlstr = $uParts["path"].($uParts["query"]?"?".$uParts["query"]:""); 01910 if (strlen($urlstr)<10) { 01911 $urlstr=$uParts["host"].$urlstr; 01912 } 01913 $urlstr=substr($urlstr,0,40); 01914 $img='<img src="'.$GLOBALS["BACK_PATH"].'gfx/zoom2.gif" width="12" height="12" border="0" title="'.htmlspecialchars($urlArr[$id]).'">'; 01915 $tblLines[]=array("Link #".$id." (".$urlstr.")",$c,$urlCounter["html"][$id],$urlCounter["plain"][$id],$img); 01916 } 01917 $output.='<BR><strong>Response:</strong>'; 01918 $output.=$this->formatTable($tblLines,array("nowrap","nowrap align=right","nowrap align=right","nowrap align=right"),1,array(0,0,0,0,1)); 01919 01920 01921 01922 // ****************** 01923 // Returned mails: 01924 // ****************** 01925 $queryArray = array('count(*) as counter,return_code', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=-127', 'return_code'); 01926 $table_ret = $this->getQueryRows($queryArray,"return_code"); 01927 $tblLines=array(); 01928 $tblLines[]=array("","Count:"); 01929 $tblLines[]=array("Total Mails returned:",$table["-127"]["counter"]); 01930 $tblLines[]=array("Recipient unknown (550):",$this->showWithPercent($table_ret["550"]["counter"]+$table_ret["553"]["counter"],$table["-127"]["counter"])); 01931 $tblLines[]=array("Mailbox full:",$this->showWithPercent($table_ret["551"]["counter"],$table["-127"]["counter"])); 01932 $tblLines[]=array("Bad host:",$this->showWithPercent($table_ret["2"]["counter"],$table["-127"]["counter"])); 01933 $tblLines[]=array("Error in Header:",$this->showWithPercent($table_ret["554"]["counter"],$table["-127"]["counter"])); 01934 $tblLines[]=array("Unknown:",$this->showWithPercent($table_ret["-1"]["counter"],$table["-127"]["counter"])); 01935 01936 $output.='<BR><strong>Returned mails:</strong>'; 01937 $output.=$this->formatTable($tblLines,array("nowrap","nowrap align=right"),1); 01938 $output.='<a href="'.$thisurl.'&returnList=1">List returned recipients</a><BR>'; 01939 $output.='<a href="'.$thisurl.'&returnDisable=1">Disable returned recipients</a><BR>'; 01940 $output.='<a href="'.$thisurl.'&returnCSV=1">CSV of returned recipients</a><BR>'; 01941 01942 if (t3lib_div::_GP("returnList")|t3lib_div::_GP("returnDisable")|t3lib_div::_GP("returnCSV")) { 01943 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('rid,rtbl', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=-127'); 01944 $idLists = array(); 01945 while($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01946 switch($rrow["rtbl"]) { 01947 case "t": 01948 $idLists["tt_address"][]=$rrow["rid"]; 01949 break; 01950 case "f": 01951 $idLists["fe_users"][]=$rrow["rid"]; 01952 break; 01953 default: 01954 $idLists[$rrow["rtbl"]][]=$rrow["rid"]; 01955 break; 01956 } 01957 } 01958 01959 if (t3lib_div::_GP("returnList")) { 01960 if (is_array($idLists["tt_address"])) {$output.="<BR>ADDRESSES".$this->getRecordList($this->fetchRecordsListValues($idLists["tt_address"],"tt_address"),"tt_address");} 01961 if (is_array($idLists["fe_users"])) {$output.="<BR>WEBSITE USERS".$this->getRecordList($this->fetchRecordsListValues($idLists["fe_users"],"fe_users"),"fe_users");} 01962 // if (is_array($idLists["PLAINLIST"])) {$out.=$this->getRecordList($idLists["PLAINLIST"],"default",1);} 01963 // if (is_array($idLists[$this->userTable])) {$out.=$this->getRecordList($this->fetchRecordsListValues($idLists[$this->userTable],$this->userTable),$this->userTable);} 01964 } 01965 if (t3lib_div::_GP("returnDisable")) { 01966 if (is_array($idLists["tt_address"])) { 01967 $c=$this->disableRecipients($this->fetchRecordsListValues($idLists["tt_address"],"tt_address"),"tt_address"); 01968 $output.="<BR>".$c." ADDRESSES DISABLED"; 01969 } 01970 if (is_array($idLists["fe_users"])) { 01971 $c=$this->disableRecipients($this->fetchRecordsListValues($idLists["fe_users"],"fe_users"),"fe_users"); 01972 $output.="<BR>".$c." FE_USERS DISABLED"; 01973 } 01974 } 01975 if (t3lib_div::_GP("returnCSV")) { 01976 $emails=array(); 01977 if (is_array($idLists["tt_address"])) { 01978 $arr=$this->fetchRecordsListValues($idLists["tt_address"],"tt_address"); 01979 reset($arr); 01980 while(list(,$v)=each($arr)) { 01981 $emails[]=$v["email"]; 01982 } 01983 } 01984 if (is_array($idLists["fe_users"])) { 01985 $arr=$this->fetchRecordsListValues($idLists["fe_users"],"fe_users"); 01986 reset($arr); 01987 while(list(,$v)=each($arr)) { 01988 $emails[]=$v["email"]; 01989 } 01990 } 01991 $output.="<BR>Email recipients which are returned mails:<BR>"; 01992 $output.='<textarea'.$GLOBALS["TBE_TEMPLATE"]->formWidthText().' rows="6" name="nothing">'.t3lib_div::formatForTextarea(implode($emails,chr(10))).'</textarea>'; 01993 } 01994 } 01995 01996 $this->noView=1; 01997 $theOutput.= $GLOBALS["SOBE"]->doc->section("Statistics for direct mail:",$output); 01998 01999 $link = '<a href="'.$thisurl.'">Re-calculate cached statistics data</a>'; 02000 $theOutput.= $GLOBALS["SOBE"]->doc->divider(10); 02001 $theOutput.= $GLOBALS["SOBE"]->doc->section("Re-calculate Cached Data:",$link); 02002 return $theOutput; 02003 } 02004 function disableRecipients($arr,$table) { 02005 if ($GLOBALS["TCA"][$table]) { 02006 $fields_values=array(); 02007 $enField = $GLOBALS["TCA"][$table]["ctrl"]["enablecolumns"]["disabled"]; 02008 if ($enField) { 02009 $fields_values[$enField]=1; 02010 $count=count($arr); 02011 $uidList = array_keys($arr); 02012 if (count($uidList)) { 02013 $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($uidList)).')', $fields_values); 02014 } 02015 } 02016 } 02017 return intval($count); 02018 } 02019 function makeStatTempTableContent($mrow) { 02020 // Remove old: 02021 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_sys_dmail_stat', 'mid='.intval($mrow['uid'])); 02022 02023 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('rid,rtbl,tstamp,response_type,url_id,html_sent,size', 'sys_dmail_maillog', 'mid='.intval($mrow['uid']), '', 'rtbl,rid,tstamp'); 02024 02025 $currentRec = ""; 02026 $recRec = ""; 02027 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 02028 $thisRecPointer=$row["rtbl"].$row["rid"]; 02029 if ($thisRecPointer!=$currentRec) { 02030 $this->storeRecRec($recRec); 02031 // debug($thisRecPointer); 02032 $recRec=array( 02033 "mid"=>intval($mrow["uid"]), 02034 "rid"=>intval($row["rid"]), 02035 "rtbl"=>$row["rtbl"], 02036 "pings"=>array(), 02037 "plain_links"=>array(), 02038 "html_links"=>array(), 02039 "response"=>array(), 02040 "links"=>array() 02041 ); 02042 $currentRec=$thisRecPointer; 02043 } 02044 switch ($row["response_type"]) { 02045 case "-1": 02046 $recRec["pings"][]=$row["tstamp"]; 02047 $recRec["response"][]=$row["tstamp"]; 02048 break; 02049 case "0": 02050 $recRec["recieved_html"]=$row["html_sent"]&1; 02051 $recRec["recieved_plain"]=$row["html_sent"]&2; 02052 $recRec["size"]=$row["size"]; 02053 $recRec["tstamp"]=$row["tstamp"]; 02054 break; 02055 case "1": 02056 case "2": 02057 $recRec[($row["response_type"]==1?"html_links":"plain_links")][] = $row["tstamp"]; 02058 $recRec["links"][]=$row["tstamp"]; 02059 if (!$recRec["firstlink"]) { 02060 $recRec["firstlink"]=$row["url_id"]; 02061 $recRec["firstlink_time"]=intval(@max($recRec["pings"])); 02062 $recRec["firstlink_time"]= $recRec["firstlink_time"] ? $row["tstamp"]-$recRec["firstlink_time"] : 0; 02063 } elseif (!$recRec["secondlink"]) { 02064 $recRec["secondlink"]=$row["url_id"]; 02065 $recRec["secondlink_time"]=intval(@max($recRec["pings"])); 02066 $recRec["secondlink_time"]= $recRec["secondlink_time"] ? $row["tstamp"]-$recRec["secondlink_time"] : 0; 02067 } elseif (!$recRec["thirdlink"]) { 02068 $recRec["thirdlink"]=$row["url_id"]; 02069 $recRec["thirdlink_time"]=intval(@max($recRec["pings"])); 02070 $recRec["thirdlink_time"]= $recRec["thirdlink_time"] ? $row["tstamp"]-$recRec["thirdlink_time"] : 0; 02071 } 02072 $recRec["response"][]=$row["tstamp"]; 02073 break; 02074 case "-127": 02075 $recRec["returned"]=1; 02076 break; 02077 } 02078 } 02079 $this->storeRecRec($recRec); 02080 } 02081 function storeRecRec($recRec) { 02082 if (is_array($recRec)) { 02083 $recRec["pings_first"] = intval(@min($recRec["pings"])); 02084 $recRec["pings_last"] = intval(@max($recRec["pings"])); 02085 $recRec["pings"] = count($recRec["pings"]); 02086 02087 $recRec["html_links_first"] = intval(@min($recRec["html_links"])); 02088 $recRec["html_links_last"] = intval(@max($recRec["html_links"])); 02089 $recRec["html_links"] = count($recRec["html_links"]); 02090 02091 $recRec["plain_links_first"] = intval(@min($recRec["plain_links"])); 02092 $recRec["plain_links_last"] = intval(@max($recRec["plain_links"])); 02093 $recRec["plain_links"] = count($recRec["plain_links"]); 02094 02095 $recRec["links_first"] = intval(@min($recRec["links"])); 02096 $recRec["links_last"] = intval(@max($recRec["links"])); 02097 $recRec["links"] = count($recRec["links"]); 02098 02099 $recRec["response_first"] = t3lib_div::intInRange(intval(@min($recRec["response"]))-$recRec["tstamp"],0); 02100 $recRec["response_last"] = t3lib_div::intInRange(intval(@max($recRec["response"]))-$recRec["tstamp"],0); 02101 $recRec["response"] = count($recRec["response"]); 02102 02103 $recRec["time_firstping"] = t3lib_div::intInRange($recRec["pings_first"]-$recRec["tstamp"],0); 02104 $recRec["time_lastping"] = t3lib_div::intInRange($recRec["pings_last"]-$recRec["tstamp"],0); 02105 02106 $recRec["time_first_link"] = t3lib_div::intInRange($recRec["links_first"]-$recRec["tstamp"],0); 02107 $recRec["time_last_link"] = t3lib_div::intInRange($recRec["links_last"]-$recRec["tstamp"],0); 02108 02109 $GLOBALS['TYPO3_DB']->exec_INSERTquery("cache_sys_dmail_stat", $recRec); 02110 } 02111 } 02112 function showQueryRes($query) { 02113 $res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db,$query); 02114 $lines = array(); 02115 $first = 1; 02116 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 02117 if ($first) { 02118 $lines[]="<tr bgcolor=#cccccc><td><b>".implode("</b></td><td><b>",array_keys($row))."</b></td></tr>"; 02119 $first=0; 02120 } 02121 $lines[]="<tr bgcolor=#eeeeee><td>".implode("</td><td>",$row)."</td></tr>"; 02122 } 02123 $str = '<table border=1 cellpadding=0 cellspacing=0>'.implode("",$lines).'</table>'; 02124 return $str; 02125 } 02126 function getQueryRows($queryArray,$key_field) { 02127 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 02128 $queryArray[0], 02129 $queryArray[1], 02130 $queryArray[2], 02131 $queryArray[3], 02132 $queryArray[4], 02133 $queryArray[5] 02134 ); 02135 $lines = array(); 02136 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 02137 if ($key_field) { 02138 $lines[$row[$key_field]] = $row; 02139 } else { 02140 $lines[] = $row; 02141 } 02142 } 02143 return $lines; 02144 } 02145 02146 function directMail_defaultView($row) { 02147 global $LANG; 02148 // Render record: 02149 $out=""; 02150 $Eparams="&edit[sys_dmail][".$row["uid"]."]=edit"; 02151 $out.='<tr><td colspan=3 class="bgColor5" valign=top>'.fw($this->fName("subject")." <b>".t3lib_div::fixed_lgd($row["subject"],30)." </b>").'</td></tr>'; 02152 02153 $nameArr = explode(",","subject,from_name,from_email,replyto_name,replyto_email,organisation,attachment,priority,sendOptions,type,page,plainParams,HTMLParams,issent,renderedsize"); 02154 while(list(,$name)=each($nameArr)) { 02155 $out.='<tr><td class="bgColor4">'.fw($this->fName($name)).'</td><td class="bgColor4">'.fw(htmlspecialchars(t3lib_BEfunc::getProcessedValue("sys_dmail",$name,$row[$name]))).'</td></tr>'; 02156 } 02157 $out='<table border=0 cellpadding=1 cellspacing=1 width=460>'.$out.'</table>'; 02158 if (!$row["issent"]) { 02159 if ($GLOBALS["BE_USER"]->check("tables_modify","sys_dmail")) { 02160 $out.='<BR><A HREF="#" onClick="'.t3lib_BEfunc::editOnClick($Eparams,$GLOBALS["BACK_PATH"],"").'"><img src="'.$GLOBALS["BACK_PATH"].'gfx/edit2.gif" width=11 height=12 hspace=2 border=0 title="Edit" align="top">'.fw("<B>".$LANG->getLL("dmail_edit")."</B>").'</a>'; 02161 } else { 02162 $out.='<BR><img src="'.$GLOBALS["BACK_PATH"].'gfx/edit2.gif" width=11 height=12 hspace=2 border=0 title="'.$LANG->getLL("dmail_edit").'" align="top">'.fw("(".$LANG->getLL("dmail_noEdit_noPerms").")"); 02163 } 02164 } else { 02165 $out.='<BR><img src="'.$GLOBALS["BACK_PATH"].'gfx/edit2.gif" width=11 height=12 hspace=2 border=0 title="'.$LANG->getLL("dmail_edit").'" align="top">'.fw("(".$LANG->getLL("dmail_noEdit_isSent").")"); 02166 } 02167 02168 if ($row["type"]==0 && $row["page"]) { 02169 $pageRow = t3lib_BEfunc::getRecord ("pages",$row["page"]); 02170 if ($pageRow) { 02171 $out.='<BR><BR>'.$LANG->getLL("dmail_basedOn").'<BR>'; 02172 $out.='<nobr><a href="index.php?id='.$this->id.'&CMD=displayPageInfo&pages_uid='.$pageRow["uid"].'&SET[dmail_mode]=news"><img src="'.$GLOBALS["BACK_PATH"].t3lib_iconWorks::getIcon("pages",$pageRow).'" width=18 height=16 border=0 title="'.htmlspecialchars(t3lib_BEfunc::getRecordPath ($pageRow["uid"],$this->perms_clause,20)).'" align=top>'.htmlspecialchars($pageRow["title"]).'</a></nobr><BR>'; 02173 } 02174 } 02175 02176 $theOutput.= $GLOBALS["SOBE"]->doc->section($LANG->getLL("dmail_view"),$out,0,1); 02177 02178 // Status: 02179 02180 $theOutput.= $GLOBALS["SOBE"]->doc->spacer(15); 02181 $menuItems = array(); 02182 $menuItems[0]="[MENU]"; 02183 if (!$row["issent"]) { 02184 $menuItems["prefetch"]="Fetch and compile maildata (read url)"; 02185 } 02186 if ($row["from_email"] && $row["renderedsize"]) { 02187 $menuItems["testmail"]="Send a testmail"; 02188 if (!$row["issent"]) { 02189 $menuItems["finalmail"]="Mass-send mail"; 02190 } 02191 } 02192 if ($row["issent"]) { 02193 $menuItems["stats"]="See statistics of this mail"; 02194 } 02195 02196 $menu = t3lib_BEfunc::getFuncMenu($this->id,"CMD","",$menuItems,"","&sys_dmail_uid=".$row["uid"]); 02197 $theOutput.= $GLOBALS["SOBE"]->doc->section("Options:",$menu); 02198 02199 if (!$row["renderedsize"]) { 02200 $theOutput.= $GLOBALS["SOBE"]->doc->divider(15); 02201 $theOutput.= $GLOBALS["SOBE"]->doc->section("Note:","Use the menu to fetch content for the email"); 02202 } elseif(!$row["from_email"]) { 02203 $theOutput.= $GLOBALS["SOBE"]->doc->divider(15); 02204 $theOutput.= $GLOBALS["SOBE"]->doc->section("Note:","You <i>must</i> enter a 'Sender email' address for the mail!"); 02205 } else { 02206 $theOutput.= $GLOBALS["SOBE"]->doc->divider(15); 02207 $theOutput.= $GLOBALS["SOBE"]->doc->section("Note:","Use the menu to send a test-mail to your own email address or finally send the mail to all recipients."); 02208 } 02209 $theOutput.= $GLOBALS["SOBE"]->doc->section('','<BR><BR><input type="submit" value="< BACK">'); 02210 return $theOutput; 02211 } 02212 function linkDMail_record($str,$uid) { 02213 return '<a href="index.php?id='.$this->id.'&sys_dmail_uid='.$uid.'&SET[dmail_mode]=direct">'.$str.'</a>'; 02214 } 02215 function linkRecip_record($str,$uid) { 02216 return '<a href="index.php?id='.$this->id.'&CMD=displayMailGroup&group_uid='.$uid.'&SET[dmail_mode]=recip">'.$str.'</a>'; 02217 } 02218 function fName($name) { 02219 return $GLOBALS["LANG"]->sL(t3lib_BEfunc::getItemLabel("sys_dmail",$name)); 02220 } 02221 function JSbottom($formname="forms[0]") { 02222 if ($this->extJSCODE) { 02223 $out.=' 02224 <script language="javascript" type="text/javascript" src="'.$GLOBALS["BACK_PATH"].'t3lib/jsfunc.evalfield.js"></script> 02225 <script language="javascript" type="text/javascript"> 02226 var evalFunc = new evalFunc; 02227 function typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { 02228 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue); 02229 var theValue = document.'.$formname.'[theField].value; 02230 if (checkbox && theValue==checkboxValue) { 02231 document.'.$formname.'[theField+"_hr"].value=""; 02232 if (document.'.$formname.'[theField+"_cb"]) document.'.$formname.'[theField+"_cb"].checked = ""; 02233 } else { 02234 document.'.$formname.'[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue); 02235 if (document.'.$formname.'[theField+"_cb"]) document.'.$formname.'[theField+"_cb"].checked = "on"; 02236 } 02237 } 02238 function typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { 02239 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue); 02240 if (checkbox_off) { 02241 document.'.$formname.'[theField].value=checkboxValue; 02242 }else{ 02243 document.'.$formname.'[theField].value = evalFunc.evalObjValue(theFObj, document.'.$formname.'[theField+"_hr"].value); 02244 } 02245 typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue); 02246 } 02247 </script> 02248 <script language="javascript" type="text/javascript">'.$this->extJSCODE.'</script>'; 02249 return $out; 02250 } 02251 } 02252 } 02253 02254 02255 02256 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/direct_mail/mod/class.mod_web_dmail.php"]) { 02257 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/direct_mail/mod/class.mod_web_dmail.php"]); 02258 } 02259 02260 ?>