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