---
title: "Direct Mail - Link Respone - Verlinkung im Backend falsch"
url: "https://www.typo3.net/d/102384-direct-mail-link-respone-verlinkung-im-backend-falsch"
source: "typo3.net"
tags: ["Extensions","Direct Mail","Frage"]
created: "2010-11-15"
last_reply: "2010-11-15"
replies: 0
solved: false
page: 1
pages: 1
lang: "de"
---

# Direct Mail - Link Respone - Verlinkung im Backend falsch

Extensions · 0 Antworten · gestartet 2010-11-15

## Eröffnungsbeitrag

**perse** · 2010-11-15 · [Beitrag #1](https://www.typo3.net/d/102384-direct-mail-link-respone-verlinkung-im-backend-falsch/1)

Hallo Zusammen,

ich habe für direct mail die Statistik aktiviert. Funktioniert soweit auch prima. Einziges Problem ist, dass im Backend unter Link Response die Verlinkung zur jeweiligen Ansicht (Lupensymbol) falsch ist.

Der Link sieht so aus:
<http://www.frokost.dk/%5Bb%5Dtypo3conf/ext/direct_mail/mod4>[/b]/index.php?id=55&tx_ttnews%5Byear%5D=2010&tx_ttnews%5Bmonth%5D=10&tx_ttnews%5Bday%5D=21&tx_ttnews%5Btt_news%5D=115&cHash=f2cfcc6466

Muss aber so lauten:
<http://www.domain.de/index.php?id=55&tx_ttnews%5Byear%5D=2010&tx_ttnews%5Bmonth%5D=10&tx_ttnews%5Bday%5D=21&tx_ttnews%5Btt_news%5D=115&cHash=f2cfcc6466>

Ich nehme an, die Datei im Ordner "typo3conf/ext/direct_mail/mod4/index.php" muss angepasst werden.
Kann da jemand helfen?

```typoscript
/***************************************************************
 *  Copyright notice
 *
 *  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  (c) 2005-2006 Jan-Erik Revsbech <jer@moccompany.com>
 *  (c) 2006 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
 *  A copy is found in the textfile GPL.txt and important notices to the license
 *  from the author is found in LICENSE.txt distributed with these scripts.
 *
 *
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/

/**
 * @author		Kasper Skï¿½rhï¿½j <kasper@typo3.com>
 * @author  	Jan-Erik Revsbech <jer@moccompany.com>
 * @author  	Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
 * @author		Ivan-Dharma Kartolo	<ivan.kartolo@dkd.de>
 *
 * @package 	TYPO3
 * @subpackage 	tx_directmail
 * @version		$Id: class.tx_directmail_statistics.php 26401 2009-11-10 23:04:52Z ivankartolo $
 */

/**
 * [CLASS/FUNCTION INDEX of SCRIPT]
 *
 *
 *
 *   80: class tx_directmail_statistics extends t3lib_SCbase
 *  107:     function init()
 *  149:     function printContent()
 *  159:     function main()
 *  243:     function moduleContent()
 *  263:     function mailModule_main()
 *  309:     function cmd_displayPageInfo()
 *  389:     function linkDMail_record($str,$uid,$aTitle)
 *  399:     function cmd_stats($row)
 * 1043:     function disableRecipients($arr,$table)
 * 1069:     function makeStatTempTableContent($mrow)
 * 1149:     function storeRecRec($recRec)
 * 1191:     function getQueryRows($queryArray,$key_field)
 * 1220:     function showWithPercent($pieces,$total)
 * 1239:     function formatTable($tableLines,$cellParams,$header,$cellcmd=array(),$tableParams='border="0" cellpadding="2" cellspacing="3"')
 * 1269:     function fetchRecordsListValues($listArr,$table,$fields='uid,name,email')
 * 1298:     function getRecordList($listArr,$table,$dim=0,$editLinkFlag=1)
 * 1338:     function setURLs($row)
 * 1378:     function getUrlBase($domainUid)
 * 1408:     function directMail_compactView($row)
 * 1463:     function fName($name)
 *
 * TOTAL FUNCTIONS: 20
 * (This index is automatically created/updated by the extension "extdeveval")
 *
 */

require_once (PATH_t3lib.'class.t3lib_scbase.php');
require_once (PATH_t3lib.'class.t3lib_page.php');
require_once(t3lib_extMgm::extPath('direct_mail').'res/scripts/class.tx_directmail_static.php');

/**
 * Module Statistics of tx_directmail extension
 *
 */
class tx_directmail_statistics extends t3lib_SCbase {
	var $extKey = 'direct_mail';
	var $TSconfPrefix = 'mod.web_modules.dmail.';
	var $fieldList='uid,name,title,email,phone,www,address,company,city,zip,country,fax,module_sys_dmail_category,module_sys_dmail_html';
	// Internal
	var $modList='';
	var $params=array();
	var $perms_clause='';
	var $pageinfo='';
	var $sys_dmail_uid;
	var $CMD;
	var $pages_uid;
	var $id;
	var $urlbase;
	var $noView;
	var $url_plain;
	var $url_html;
	var $sys_language_uid = 0;
	var $allowedTables = array('tt_address','fe_users');
	var $MCONF;
	var $cshTable;
	var $formname = 'dmailform';

	/**
	 * first initialization of global variables
	 *
	 * @return	void		no return values: initialize global variables
	 */
	function init()	{
		global $LANG,$BACK_PATH,$TCA,$TYPO3_CONF_VARS,$TYPO3_DB;

		$this->MCONF = $GLOBALS['MCONF'];

		parent::init();

		$this->modList = t3lib_BEfunc::getListOfBackendModules(array('dmail'),$this->perms_clause,$BACK_PATH);
		$this->MOD_MENU['dmail_mode'] = t3lib_BEfunc::unsetMenuItems($this->params,$this->MOD_MENU['dmail_mode'],'menu.dmail_mode');

			// initialize the page selector
		$this->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
		$this->sys_page->init(true);

			// initialize backend user language
		if ($LANG->lang && t3lib_extMgm::isLoaded('static_info_tables')) {
			$res = $TYPO3_DB->exec_SELECTquery(
				'sys_language.uid',
				'sys_language LEFT JOIN static_languages ON sys_language.static_lang_isocode=static_languages.uid',
				'static_languages.lg_typo3='.$TYPO3_DB->fullQuoteStr($LANG->lang,'static_languages').
					t3lib_BEfunc::BEenableFields('sys_language').
					t3lib_BEfunc::deleteClause('sys_language').
					t3lib_BEfunc::deleteClause('static_languages')
				);
			while($row = $TYPO3_DB->sql_fetch_assoc($res)) {
				$this->sys_language_uid = $row['uid'];
			}
		}
			// load contextual help
		$this->cshTable = '_MOD_'.$this->MCONF['name'];
		if ($BE_USER->uc['edit_showFieldHelp']){
			$LANG->loadSingleTableDescription(q);
		}

		t3lib_div::loadTCA('sys_dmail');
	}

	/**
	 * Prints out the module HTML
	 *
	 * @return	void		no return values: print out the global variable 'content'
	 */
	function printContent()	{
		$this->content.=$this->doc->endPage();
		echo $this->content;
	}

	/**
	 * The main function.
	 *
	 * @return	void		no return value: update the global variable 'content'
	 */
	function main()	{
		global $BE_USER,$LANG,$BACK_PATH,$TCA,$TYPO3_CONF_VARS;

		$this->CMD = t3lib_div::_GP('CMD');
		$this->pages_uid=t3lib_div::_GP('pages_uid');
		$this->sys_dmail_uid=t3lib_div::_GP('sys_dmail_uid');
		$this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
		$access = is_array($this->pageinfo) ? 1 : 0;

		if (($this->id && $access) || ($BE_USER->user['admin'] && !$this->id))	{

			// Draw the header.
			$this->doc = t3lib_div::makeInstance('template');
			$this->doc->backPath = $BACK_PATH;
			$this->doc->form='<form action="" method="post" name="'.$this->formname.'" enctype="multipart/form-data">';

			// Add CSS
			$this->doc->inDocStyles = '
					a.bubble {position:relative; z-index:24; color:#000; text-decoration:none}
					a.bubble:hover {z-index:25; background-color: #e6e8ea;}
					a.bubble span.help {display: none;}
					a.bubble:hover span.help {display:block; position:absolute; top:2em; left:2em; width:25em; border:1px solid #0cf; background-color:#cff; padding: 2px;}
					td { vertical-align: top; }
					.stats-table { border: 1px solid #c0c0c0; width: 600px; border-collapse: collapse; }
					.stats-table td { border: 1px solid #c0c0c0; }
					.stats-table a { text-decoration: underline; }
					';

			// JavaScript
			$this->doc->JScode = '
				<script language="javascript" type="text/javascript">
					script_ended = 0;
					function jumpToUrl(URL)	{ //
						window.location.href = URL;
					}
					function jumpToUrlD(URL) { //
						window.location.href = URL+"&sys_dmail_uid='.$this->sys_dmail_uid.'";
					}
				</script>
			';

			$this->doc->postCode='
				<script language="javascript" type="text/javascript">
					script_ended = 1;
					if (top.fsMod) top.fsMod.recentIds[\'web\'] = '.intval($this->id).';
				</script>
			';

			$module = $this->pageinfo['module'];
			if (!$module)	{
				$pidrec=t3lib_BEfunc::getRecord('pages',intval($this->pageinfo['pid']));
				$module=$pidrec['module'];
			}
			
			$headerSection = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path').': '.t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'],50);
			
			if ($module == 'dmail') {
					// Render content:

				$this->content.=$this->doc->startPage($LANG->getLL('stats_overview_header'));
				$this->content.=$this->doc->section('',$headerSection,1,0,0,TRUE);
				$this->content.=$this->doc->section($LANG->getLL('stats_overview_header').t3lib_BEfunc::cshItem($this->cshTable,'',$BACK_PATH), '', 1, 1, 0 , TRUE);
				$this->moduleContent();
			} else {
				$this->content.=$this->doc->startPage($LANG->getLL('stats_overview_header'));
				$this->content.=$this->doc->section('',$headerSection,1,0,0,TRUE);
				$this->content.=$this->doc->section($LANG->getLL('header_stat'), $LANG->getLL('select_folder'), 1, 1, 0 , TRUE);
			}

			// ShortCut
			if ($BE_USER->mayMakeShortcut())	{
				$this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('id',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']));
			}
			$this->content.=$this->doc->spacer(10);

		} else {
			// If no access or if ID == zero

			$this->doc = t3lib_div::makeInstance('mediumDoc');
			$this->doc->backPath = $BACK_PATH;

			$this->content.=$this->doc->startPage($LANG->getLL('title'));
			$this->content.=$this->doc->header($LANG->getLL('title'));
			$this->content.=$this->doc->spacer(5);
			$this->content.=$this->doc->spacer(10);
		}
	}

	/**
	 * compiled content of the module
	 *
	 * @return	string		The compiled content of the module.
	 */
	function moduleContent() {
		global $TYPO3_CONF_VARS, $LANG;

		if ($this->pageinfo['doktype']==254 && $this->pageinfo['module']=='dmail')	{	// Direct mail module
			$theOutput.= $this->mailModule_main();
		} elseif ($this->id!=0) {
			$theOutput.= $this->doc->section($LANG->getLL('dmail_newsletters'),'<span class="typo3-red">'.$GLOBALS['LANG']->getLL('dmail_noRegular').'</span>',0,1);
		}

		if ($this->id!=0) {
			$theOutput.=$this->doc->spacer(10);
		}
		$this->content .= $theOutput;
	}

	/**
	 * Function mailModule main()
	 *
	 * @return	string		the compiled content of the module
	 */
	function mailModule_main()	{
		global $LANG, $TYPO3_DB, $TYPO3_CONF_VARS;

		if (!$this->sys_dmail_uid)	{
			$theOutput.= $this->cmd_displayPageInfo();
		} else {
				// Here the single dmail record is shown.
			$this->sys_dmail_uid = intval($this->sys_dmail_uid);
			$res = $TYPO3_DB->exec_SELECTquery(
				'*',
				'sys_dmail',
				'pid='.intval($this->id).
					' AND uid='.intval($this->sys_dmail_uid).
					t3lib_BEfunc::deleteClause('sys_dmail')
				);

			$this->noView = 0;

			if ($row = $TYPO3_DB->sql_fetch_assoc($res)) {
					// Set URL data for commands
				$this->setURLs($row);

					// COMMAND:
					//TODO: add cmd_displayUserInfo s. recip-list
				switch($this->CMD) {
					case 'displayUserInfo':
						$theOutput.= $this->cmd_displayUserInfo();
					break;
					case 'stats':
						$theOutput .= $this->cmd_stats($row);
					break;
				default:
						// Hook for handling of custom direct mail commands:
					if (is_array($TYPO3_CONF_VARS['EXT']['directmail']['handledirectmailcmd-'.$this->CMD])) {
						foreach($TYPO3_CONF_VARS['EXT']['directmail']['handledirectmailcmd-'.$this->CMD] as $_funcRef) {
							$_params = array('pObj' => &$this);
							$theOutput .= t3lib_div::callUserFunction($_funcRef,$_params,$this);
						}
					}
				}
			}
		}
		return $theOutput;
	}
	
	/**
	 * shows user's info and categories
	 *
	 * @return	string		HTML showing user's info and the categories
	 */
	function cmd_displayUserInfo()	{
		global $TCA, $LANG, $TYPO3_DB, $BACK_PATH;
		$uid = intval(t3lib_div::_GP('uid'));
		$indata = t3lib_div::_GP('indata');
		$table=t3lib_div::_GP('table');
		t3lib_div::loadTCA($table);
		$mm_table = $TCA[$table]['columns']['module_sys_dmail_category']['config']['MM'];
		
		if(t3lib_div::_GP('submit')){
			$indata = t3lib_div::_GP('indata');
			if(!$indata){
				$indata['html']= 0;
			}
		}

		switch($table)	{
		case 'tt_address':
		case 'fe_users':
			if (is_array($indata))	{
				$data=array();
				if (is_array($indata['categories']))	{
					reset($indata['categories']);
					while(list($recUid,$recValues)=each($indata['categories']))	{
						reset($recValues);
						$enabled = array();
						while(list($k,$b)=each($recValues))	{
							if ($b)	{
								$enabled[] = $k;

							}
						}
						$data[$table][$uid]['module_sys_dmail_category'] = implode(',',$enabled);
					}
				}
				$data[$table][$uid]['module_sys_dmail_html'] = $indata['html'] ? 1 : 0;
				$tce = t3lib_div::makeInstance('t3lib_TCEmain');
				$tce->stripslashes_values=0;
				$tce->start($data,Array());
				$tce->process_datamap();
			}
			break;
		}

		switch($table)	{
		case 'tt_address':
			$res = $TYPO3_DB->exec_SELECTquery(
				'tt_address.*',
				'tt_address LEFT JOIN pages ON pages.uid=tt_address.pid',
				'tt_address.uid='.intval($uid).
					' AND '.$this->perms_clause.
					t3lib_BEfunc::deleteClause('pages').
					t3lib_BEfunc::BEenableFields('tt_address').
					t3lib_BEfunc::deleteClause('tt_address')
				);
			$row = $TYPO3_DB->sql_fetch_assoc($res);
			break;
		case 'fe_users':
			$res = $TYPO3_DB->exec_SELECTquery(
				'fe_users.*',
				'fe_users LEFT JOIN pages ON pages.uid=fe_users.pid',
				'fe_users.uid='.intval($uid).
					' AND '.$this->perms_clause.
					t3lib_BEfunc::deleteClause('pages').
					t3lib_BEfunc::BEenableFields('fe_users').
					t3lib_BEfunc::deleteClause('fe_users')
				);
			$row = $TYPO3_DB->sql_fetch_assoc($res);
			break;
		}
		if (is_array($row))	{
			$row_categories = '';
			$resCat = $TYPO3_DB->exec_SELECTquery(
				'uid_foreign',
				$mm_table,
				'uid_local='.$row['uid']
				);
			while($rowCat=$TYPO3_DB->sql_fetch_assoc($resCat)) {
				$row_categories .= $rowCat['uid_foreign'].',';
			}
			$row_categories = t3lib_div::rm_endComma($row_categories);

			$Eparams='&edit['.$table.']['.$row['uid'].']=edit';
			$out='';
			$out.= t3lib_iconWorks::getIconImage($table, $row, $BACK_PATH, 'width="18" height="16" title="'.htmlspecialchars(t3lib_BEfunc::getRecordPath ($row['pid'],$this->perms_clause,40)).'" style="vertical-align:top;"').htmlspecialchars($row['name'].' <'.$row['email'].'>');
			$out.='  <a href="#" onClick="'.t3lib_BEfunc::editOnClick($Eparams,$BACK_PATH,'').'"><img'.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/edit2.gif', 'width="12" height="12"').' alt="'.$LANG->getLL("dmail_edit").'" width="12" height="12" style="margin: 2px 3px; vertical-align:top;" title="'.$LANG->getLL("dmail_edit").'" />' . fw('<b>' . $LANG->getLL('dmail_edit') . '</b>').'</a>';
			$theOutput.= $this->doc->section($LANG->getLL('subscriber_info'),$out);

			$out='';
			$out_check='';

			$this->categories = tx_directmail_static::makeCategories($table, $row, $this->sys_language_uid);
			reset($this->categories);
			while(list($pKey,$pVal)=each($this->categories))	{
				$out_check.='<input type="hidden" name="indata[categories]['.$row['uid'].']['.$pKey.']" value="0" /><input type="checkbox" name="indata[categories]['.$row['uid'].']['.$pKey.']" value="1"'.(t3lib_div::inList($row_categories,$pKey)?' checked="checked"':'').' /> '.htmlspecialchars($pVal).'<br />';
			}
			$out_check.='<br /><br /><input type="checkbox" name="indata[html]" value="1"'.($row['module_sys_dmail_html']?' checked="checked"':'').' /> ';
			$out_check.=$LANG->getLL('subscriber_profile_htmlemail') . '<br />';
			$out.=fw($out_check);

			$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" name="submit" value="' . htmlspecialchars($LANG->getLL('subscriber_profile_update')) . '" />';
			$theOutput.= $this->doc->spacer(20);
			$theOutput.= $this->doc->section($LANG->getLL('subscriber_profile'), $LANG->getLL('subscriber_profile_instructions') . '<br /><br />'.$out);
		}
		return $theOutput;
	}
	
	/**
	 * shows the info of a page
	 *
	 * @return	string		The infopage of the sent newsletters
	 */
	function cmd_displayPageInfo()	{
		global $TCA, $LANG, $TYPO3_DB, $BACK_PATH;

			// Here the dmail list is rendered:
		$res = $TYPO3_DB->exec_SELECTquery(
			'*',
			'sys_dmail',
			'pid='.intval($this->id).
				' AND type=0'.
				' AND issent = 1'.
				t3lib_BEfunc::deleteClause('sys_dmail'),
			'',
			'scheduled DESC, scheduled_begin DESC'
			);

		if ($TYPO3_DB->sql_num_rows($res))	{
			$onClick = ' onClick="return confirm('.$LANG->JScharCode(sprintf($LANG->getLL('nl_l_warning'),$TYPO3_DB->sql_num_rows($res))).');"';
		} else {
			$onClick = '';
		}
		$out="";

		if ($TYPO3_DB->sql_num_rows($res))	{
			$out.='<table cellspacing="0" cellpadding="3" class="stats-table">';
				$out.='<tr class="bgColor2">
					<td>'.fw(' ').'</td>
					<td><b>'.fw($LANG->getLL('stats_overview_subject')).'</b></td>
					<td><b>'.fw($LANG->getLL('stats_overview_scheduled')).'</b></td>
					<td><b>'.fw($LANG->getLL('stats_overview_delivery_begun')).'</b></td>
					<td><b>'.fw($LANG->getLL('stats_overview_delivery_ended')).'</b></td>
					<td nowrap="nowrap"><b>'.fw($LANG->getLL('stats_overview_total_sent')).'</b></td>
					<td><b>'.fw($LANG->getLL('stats_overview_status')).'</b></td>
				</tr>';
			while($row = $TYPO3_DB->sql_fetch_assoc($res))	{

				$countRes = $TYPO3_DB->exec_SELECTquery(
					'count(*)',
					'sys_dmail_maillog',
					'mid = '.$row['uid'].' AND response_type=0'
				);
				list($count) = $TYPO3_DB->sql_fetch_row($countRes);

				$sent='';
				if(!empty($row['scheduled_begin'])){
					if(!empty($row['scheduled_end']))
						$sent = fw($LANG->getLL('stats_overview_sent'));
					else
						$sent = fw($LANG->getLL('stats_overview_sending'));
				} else {
					$sent = fw($LANG->getLL('stats_overview_queuing'));
				}

				$out.='<tr class="bgColor4">
					<td>'.t3lib_iconWorks::getIconImage('sys_dmail',$row, $BACK_PATH, 'width="18" height="16" style="vertical-align: top;"').'</td>
					<td>'.$this->linkDMail_record(fw(t3lib_div::fixed_lgd($row['subject'],30).'  '),$row['uid'],$row['subject']).'  </td>
					<td>'.fw(t3lib_BEfunc::datetime($row["scheduled"])).'</td>
					<td>'.fw($row["scheduled_begin"]?t3lib_BEfunc::datetime($row["scheduled_begin"]):' ').'</td>
					<td>'.fw($row["scheduled_end"]?t3lib_BEfunc::datetime($row["scheduled_end"]):' ').'</td>
					<td>'.fw($count?$count:' ').'</td>
					<td>'.$sent.'</td>
				</tr>';
			}
			$out.='</table>';
		}

		$theOutput.= $this->doc->section($LANG->getLL('stats_overview_choose'), $out , 1, 1, 0, TRUE);
		$theOutput.= $this->doc->spacer(20);

		return $theOutput;
	}

	/**
	 * wrap a string with a link
	 *
	 * @param	string		$str: string to be wrapped with a link
	 * @param	integer		$uid: record uid to be link
	 * @param	string		$aTitle: title param of the link tag
	 * @return	string		wrapped string as a link
	 */
	function linkDMail_record($str,$uid,$aTitle='')	{
		return '<a title="'.htmlspecialchars($aTitle).'" href="index.php?id='.$this->id.'&sys_dmail_uid='.$uid.'&SET[dmail_mode]=direct&CMD=stats">'.htmlspecialchars($str).'</a>';
	}

	/**
	 * get statistics from DB and compile them.
	 *
	 * @param	array		$row: DB record
	 * @return	string		statistics of a mail
	 */
	function cmd_stats($row)	{
		global $LANG, $BACK_PATH, $TYPO3_DB, $TBE_TEMPLATE;

		if (t3lib_div::_GP("recalcCache"))	{
			$this->makeStatTempTableContent($row);
		}
		$thisurl = 'index.php?id='.$this->id.'&sys_dmail_uid='.$row['uid'].'&CMD='.$this->CMD.'&recalcCache=1';
		$output = $this->directMail_compactView($row);

			// *****************************
			// Mail responses, general:
			// *****************************

		$mailingId = intval($row['uid']);
		$queryArray = array('response_type,count(*) as counter', 'sys_dmail_maillog', 'mid=' . $mailingId, 'response_type');
		$table = $this->getQueryRows($queryArray, 'response_type');

			// Plaintext/HTML
		$queryArray = array('html_sent,count(*) as counter', 'sys_dmail_maillog', 'mid=' . $mailingId . ' AND response_type=0', 'html_sent');
		$table2 = $this->getQueryRows($queryArray, 'html_sent');

			// Unique responses, html
		$res = $TYPO3_DB->exec_SELECTquery('count(*) as counter', 'sys_dmail_maillog', 'mid=' . $mailingId . ' AND response_type=1', 'rid,rtbl', 'counter');
		$unique_html_responses = $TYPO3_DB->sql_num_rows($res);

			// Unique responses, Plain
		$res = $TYPO3_DB->exec_SELECTquery('count(*) as counter', 'sys_dmail_maillog', 'mid=' . $mailingId . ' AND response_type=2', 'rid,rtbl', 'counter');
		$unique_plain_responses = $TYPO3_DB->sql_num_rows($res);

			// Unique responses, pings
		$res = $TYPO3_DB->exec_SELECTquery('count(*) as counter', 'sys_dmail_maillog', 'mid=' . $mailingId . ' AND response_type=-1', 'rid,rtbl', 'counter');
		$unique_ping_responses = $TYPO3_DB->sql_num_rows($res);

		$tblLines = array();
		$tblLines[]=array('',$LANG->getLL('stats_total'),$LANG->getLL('stats_HTML'),$LANG->getLL('stats_plaintext'));

		$sent_total = intval($table['0']['counter']);
		$sent_html = intval($table2['3']['counter']+$table2['1']['counter']);
		$sent_plain = intval($table2['2']['counter']);
		$tblLines[]=array($LANG->getLL('stats_mails_sent'),$sent_total,$sent_html,$sent_plain);
		$tblLines[]=array($LANG->getLL('stats_mails_returned'),$this->showWithPercent($table['-127']['counter'],$sent_total));
		$tblLines[]=array($LANG->getLL('stats_HTML_mails_viewed'),'',$this->showWithPercent($unique_ping_responses,$sent_html));
		$tblLines[]=array($LANG->getLL('stats_unique_responses'),$this->showWithPercent($unique_html_responses+$unique_plain_responses,$sent_total),$this->showWithPercent($unique_html_responses,$sent_html),$this->showWithPercent($unique_plain_responses,$sent_plain?$sent_plain:$sent_html));

		$output.='<br /><h2>' . $LANG->getLL('stats_general_information') . '</h2>';
		$output.= tx_directmail_static::formatTable($tblLines,array('nowrap','nowrap align="right"','nowrap align="right"','nowrap align="right"'),1, array(), 'cellspacing="0" cellpadding="3" class="stats-table"');

			// ******************
			// Links:
			// ******************

			// initialize $urlCounter
		$urlCounter = array(
			'total' => array(),
			'plain' => array(),
			'html' => array(),
		);
			// Most popular links, html:
		$queryArray = array('url_id,count(*) as counter', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=1', 'url_id', 'counter');
		$htmlUrlsTable=$this->getQueryRows($queryArray,'url_id');

			// Most popular links, plain:
		$queryArray = array('url_id,count(*) as counter', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=2', 'url_id', 'counter');
		$plainUrlsTable=$this->getQueryRows($queryArray,'url_id');


		// Find urls:
		$temp_unpackedMail = unserialize($row['mailContent']);
		// this array will include a unique list of all URLs that are used in the mailing
		$urlArr = array();

		$urlMd5Map = array();
		if (is_array($temp_unpackedMail['html']['hrefs'])) {
			foreach ($temp_unpackedMail['html']['hrefs'] as $k => $v) {
				$urlArr[$k] = html_entity_decode($v['absRef']);	// convert & of query params back
				$urlMd5Map[md5($v['absRef'])] = $k;
			}
		}
		if (is_array($temp_unpackedMail['plain']['link_ids'])) {
			foreach ($temp_unpackedMail['plain']['link_ids'] as $k => $v) {
				$urlArr[intval(-$k)] = $v;
			}
		}

		// Traverse plain urls:
		$plainUrlsTable_mapped = array();
		foreach ($plainUrlsTable as $id => $c) {
			$url = $urlArr[intval($id)];
			if (isset($urlMd5Map[md5($url)])) {
				$plainUrlsTable_mapped[$urlMd5Map[md5($url)]] = $c;
			} else {
				$plainUrlsTable_mapped[$id] = $c;
			}
		}

		// Traverse html urls:
		$urlCounter['html'] = array();
		foreach ($htmlUrlsTable as $id => $c) {
			$urlCounter['html'][$id]['counter'] = $urlCounter['total'][$id]['counter'] = $c['counter'];
		}

		// Traverse plain urls:
		$urlCounter['plain'] = array();
		foreach ($plainUrlstable_mapped as $id => $c) {
			// Look up plain url in html urls
			$htmlLinkFound = FALSE;
			foreach ($urlCounter['html'] as $htmlId => $htmlLink) {
				if ($urlArr[$id] == $urlArr[$htmlId]) {
					$urlCounter['html'][$htmlId]['plainId'] = $id;
					$urlCounter['html'][$htmlId]['plainCounter'] = $c['counter'];
					$urlCounter['total'][$htmlId]['counter'] = $urlCounter['total'][$htmlId]['counter'] + $c['counter'];
					$htmlLinkFound = TRUE;
					break;
				}
			}
			if (!$htmlLinkFound) {
				$urlCounter['plain'][$id]['counter'] = $c['counter'];
				$urlCounter['total'][$id]['counter'] = $urlCounter['total'][$id]['counter'] + $c['counter'];
			}
		}

		$tblLines=array();
		$tblLines[]=array('',$LANG->getLL('stats_total'),$LANG->getLL('stats_HTML'),$LANG->getLL('stats_plaintext'));
		$tblLines[]=array($LANG->getLL('stats_total_responses'),$table['1']['counter']+$table['2']['counter'],$table['1']['counter']?$table['1']['counter']:'0',$table['2']['counter']?$table['2']['counter']:'0');
		$tblLines[]=array($LANG->getLL('stats_unique_responses'),$this->showWithPercent($unique_html_responses+$unique_plain_responses,$sent_total), $this->showWithPercent($unique_html_responses,$sent_html), $this->showWithPercent($unique_plain_responses,$sent_plain?$sent_plain:$sent_html));
		$tblLines[]=array($LANG->getLL('stats_links_clicked_per_respondent'),
			($unique_html_responses+$unique_plain_responses ? number_format(($table['1']['counter']+$table['2']['counter'])/($unique_html_responses+$unique_plain_responses),2) : '-'),
			($unique_html_responses  ? number_format(($table['1']['counter'])/($unique_html_responses),2)  : '-'),
			($unique_plain_responses ? number_format(($table['2']['counter'])/($unique_plain_responses),2) : '-')
		);

		$output.='<br /><h2>' . $LANG->getLL('stats_response') . '</h2>';
		$output.=tx_directmail_static::formatTable($tblLines,array('nowrap','nowrap align="right"','nowrap align="right"','nowrap align="right"'),1,array(0,0,0,0), 'cellspacing="0" cellpadding="3" class="stats-table"');

		arsort($urlCounter['total']);
		arsort($urlCounter['html']);
		arsort($urlCounter['plain']);
		reset($urlCounter['total']);

		$tblLines = array();
		$tblLines[] = array('',$LANG->getLL('stats_HTML_link_nr'),$LANG->getLL('stats_plaintext_link_nr'),$LANG->getLL('stats_total'),$LANG->getLL('stats_HTML'),$LANG->getLL('stats_plaintext'),'');

			// HTML mails
		if (t3lib_div::inList('2,3', $row['sendOptions'])) {
			$HTMLContent = base64_decode($temp_unpackedMail['html']['content']);

			$HTMLLinks = array();
			foreach ($temp_unpackedMail['html']['hrefs'] as $jumpurlId => $data) {
				$HTMLlinks[$jumpurlId] = array(
					'url'   => $data['ref'],
					'label' => ''
				);
			}

				// get body
			$tmp = explode('<body', $HTMLContent);
			$bodyPart = explode('<', $tmp[1]);

				// load all <a href="*" parts into $tempHref array, in a 2-dimensional array
				// where the lower level of the array contains two values, the URL and the unique ID (see $urlArr)
			foreach ($bodyPart as $k => $str) {
				if (eregi('a.href', $str)) {
					$tagAttr = t3lib_div::get_tag_attributes($bodyPart[$k]);
					if (strpos($str, '>') === strlen($str) - 1) {
						if ($tagAttr['href']{0} != '#') {
							list($url, $jumpurlId) = explode('jumpurl=', $tagAttr['href']);
							$url = $HTMLlinks[$jumpurlId]['url'];
							$label = $LANG->getLL('stats_img_link') . '<span title="'.$url.'">' . t3lib_div::fixed_lgd_cs(substr($url, 7), 40) . '</span>';
							$HTMLlinks[$jumpurlId]['label'] = $label;
						}
					} else {
						if ($tagAttr['href']{0} != '#') {
							list($url, $jumpurlId) = explode('jumpurl=', $tagAttr['href']);
							$wordPos = strpos($str, '>');
							$label = substr($str, $wordPos+1);
							$HTMLlinks[$jumpurlId]['label'] = $label;
						}
					}
				}
			}
		}

		foreach ($urlCounter['total'] as $id => $hits) {
				// $id is the jumpurl ID
			$id     = abs(intval($id));
			$url    = $HTMLlinks[$id]['url'];
				// a link to this host?
			$uParts = @parse_url($url);
			$urlstr = $this->getUrlStr($uParts);

			$label = $HTMLlinks[$id]['label'].' (' . ($urlstr ? $urlstr : '/') . ')';
			$img = '<a href="'.htmlspecialchars($url).'"><img '.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/zoom.gif', 'width="12" height="12"').' title="'.htmlspecialchars($url).'" /></a>';

			if (isset($urlCounter['html'][$id]['plainId']))	{
				$tblLines[] = array(
					$label,
					$id,
					$urlCounter['html'][$id]['plainId'],
					$urlCounter['total'][$id]['counter'],
					$urlCounter['html'][$id]['counter'],
					$urlCounter['html'][$id]['plainCounter'],
					$img
				);
			} else	{
				$html = (empty($urlCounter['html'][$id]['counter']) ? 0 : 1);
				$tblLines[] = array(
					$label,
					($html ? $id : '-'),
					($html ? '-' : abs($id)),
					($html ? $urlCounter['html'][$id]['counter'] : $urlCounter['plain'][$id]['counter']),
					$urlCounter['html'][$id]['counter'],
					$urlCounter['plain'][$id]['counter'],
					$img
				);
			}
		}


			// go through all links that were not clicked yet and that have a label
		$clickedLinks = array_keys($urlCounter['total']);
		foreach ($urlArr as $id => $link) {
			if (!in_array($id, $clickedLinks) && (isset($HTMLlinks['id']))) {
					// a link to this host?
				$uParts = @parse_url($link);
				$urlstr = $this->getUrlStr($uParts);

				$label = $HTMLlinks[$id]['label'] . ' (' . ($urlstr ? $urlstr : '/') . ')';
				$img = '<a href="' . htmlspecialchars($link) . '"><img ' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/zoom.gif', 'width="12" height="12"') . ' title="' . htmlspecialchars($link) . '" /></a>';
				$tblLines[] = array(
					$label,
					($html ? $id : '-'),
					($html ? '-' : abs($id)),
					($html ? $urlCounter['html'][$id]['counter'] : $urlCounter['plain'][$id]['counter']),
					$urlCounter['html'][$id]['counter'],
					$urlCounter['plain'][$id]['counter'],
					$img
				);
			}
		}

		if ($urlCounter['total']) {
			$output .= '<br /><h2>' . $LANG->getLL('stats_response_link') . '</h2>';
			$output .= tx_directmail_static::formatTable($tblLines, array('nowrap','nowrap width="100"','nowrap width="100"','nowrap align="right"','nowrap align="right"','nowrap align="right"','nowrap align="right"'),1,array(1,0,0,0,0,0,1), ' cellspacing="0" cellpadding="3"  class="stats-table"');
		}




		// ******************
		// Returned mails
		// ******************

			//The icons:
		$listIcons = '<img '.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/list.gif', 'width="12" height="12" alt=""').' />';
		$csvIcons = '<img '.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/csv.gif', 'width="27" height="12" alt=""').' />';
		if(t3lib_extMgm::isLoaded('tt_address')){
			$iconPath = t3lib_extMgm::extRelPath('tt_address').'ext_icon__h.gif';
			$iconParam = 'width="18" height="16"' ;
		} else {
			$iconPath = 'gfx/button_hide.gif';
			$iconParam = 'width="11" height="10"';
		}
		$hideIcons = '<img '.t3lib_iconWorks::skinImg($BACK_PATH, $iconPath, $iconParam.' alt=""').' />';

			//icons mails returned
		$iconsMailReturned[]='<a href="'.$thisurl.'&returnList=1" class="bubble">' . $listIcons.'<span class="help">'.$LANG->getLL('stats_list_returned') . '</span></a>';
		$iconsMailReturned[]='<a href="'.$thisurl.'&returnDisable=1" class="bubble">' . $hideIcons.'<span class="help">'.$LANG->getLL('stats_disable_returned') . '</span></a>';
		$iconsMailReturned[]='<a href="'.$thisurl.'&returnCSV=1" class="bubble">' . $csvIcons.'<span class="help">'.$LANG->getLL('stats_CSV_returned') . '</span></a>';

			//icons unknown recip
		$iconsUnknownRecip[] ='<a href="'.$thisurl.'&unknownList=1" class="bubble">' . $listIcons.'<span class="help">'.$LANG->getLL('stats_list_returned_unknown_recipient') . '</span></a>';
		$iconsUnknownRecip[] ='<a href="'.$thisurl.'&unknownDisable=1" class="bubble">' . $hideIcons.'<span class="help">'.$LANG->getLL('stats_disable_returned_unknown_recipient') . '</span></a>';
		$iconsUnknownRecip[] ='<a href="'.$thisurl.'&unknownCSV=1" class="bubble">' . $csvIcons.'<span class="help">'.$LANG->getLL('stats_CSV_returned_unknown_recipient') . '</span></a>';

			//icons mailbox full
		$iconsMailbox[] ='<a href="'.$thisurl.'&fullList=1" class="bubble">' . $listIcons.'<span class="help">'.$LANG->getLL('stats_list_returned_mailbox_full') . '</span></a>';
		$iconsMailbox[] ='<a href="'.$thisurl.'&fullDisable=1" class="bubble">' . $hideIcons.'<span class="help">'.$LANG->getLL('stats_disable_returned_mailbox_full') . '</span></a>';
		$iconsMailbox[] ='<a href="'.$thisurl.'&fullCSV=1" class="bubble">' . $csvIcons.'<span class="help">'.$LANG->getLL('stats_CSV_returned_mailbox_full') . '</span></a>';

			//icons bad host
		$iconsBadhost[] ='<a href="'.$thisurl.'&badHostList=1" class="bubble">' . $listIcons.'<span class="help">'.$LANG->getLL('stats_list_returned_bad_host') . '</span></a>';
		$iconsBadhost[] ='<a href="'.$thisurl.'&badHostDisable=1" class="bubble">' . $hideIcons.'<span class="help">'.$LANG->getLL('stats_disable_returned_bad_host') . '</span></a>';
		$iconsBadhost[] ='<a href="'.$thisurl.'&badHostCSV=1" class="bubble">' . $csvIcons.'<span class="help">'.$LANG->getLL('stats_CSV_returned_bad_host') . '</span></a>';

			//icons bad header
		$iconsBadheader[] ='<a href="'.$thisurl.'&badHeaderList=1" class="bubble">' . $listIcons.'<span class="help">'.$LANG->getLL('stats_list_returned_bad_header') . '</span></a>';
		$iconsBadheader[] ='<a href="'.$thisurl.'&badHeaderDisable=1" class="bubble">' . $hideIcons.'<span class="help">'.$LANG->getLL('stats_disable_returned_bad_header') . '</span></a>';
		$iconsBadheader[] ='<a href="'.$thisurl.'&badHeaderCSV=1" class="bubble">' . $csvIcons.'<span class="help">'.$LANG->getLL('stats_CSV_returned_bad_header') . '</span></a>';

			//icons unknown reasons
			//TODO: link to show all reason
		$iconsUnknownReason[] ='<a href="'.$thisurl.'&reasonUnknownList=1" class="bubble">' . $listIcons.'<span class="help">'.$LANG->getLL('stats_list_returned_reason_unknown') . '</span></a>';
		$iconsUnknownReason[] ='<a href="'.$thisurl.'&reasonUnknownDisable=1" class="bubble">' . $hideIcons.'<span class="help">'.$LANG->getLL('stats_disable_returned_reason_unknown') . '</span></a>';
		$iconsUnknownReason[] ='<a href="'.$thisurl.'&reasonUnknownCSV=1" class="bubble">' . $csvIcons.'<span class="help">'.$LANG->getLL('stats_CSV_returned_reason_unknown') . '</span></a>';

			//Table with Icon
		$queryArray = array('count(*) as counter,return_code', 'sys_dmail_maillog', 'mid='.intval($row['uid']).' AND response_type=-127', 'return_code');
		$table_ret = $this->getQueryRows($queryArray,'return_code');

		$tblLines=array();
		$tblLines[]=array('',$LANG->getLL('stats_count'),'');
		$tblLines[]=array($LANG->getLL('stats_total_mails_returned'), ($table['-127']['counter']?number_format(intval($table['-127']['counter'])):'0'), implode('  ',$iconsMailReturned));
		$tblLines[]=array($LANG->getLL('stats_recipient_unknown'), $this->showWithPercent($table_ret['550']['counter']+$table_ret['553']['counter'],$table['-127']['counter']), implode('  ',$iconsUnknownRecip));
		$tblLines[]=array($LANG->getLL('stats_mailbox_full'), $this->showWithPercent($table_ret['551']['counter'],$table['-127']['counter']), implode('  ',$iconsMailbox));
		$tblLines[]=array($LANG->getLL('stats_bad_host'), $this->showWithPercent($table_ret['552']['counter'],$table['-127']['counter']), implode('  ',$iconsBadhost));
		$tblLines[]=array($LANG->getLL('stats_error_in_header'), $this->showWithPercent($table_ret['554']['counter'],$table['-127']['counter']),implode('  ',$iconsBadheader));
		$tblLines[]=array($LANG->getLL('stats_reason_unkown'), $this->showWithPercent($table_ret['-1']['counter'],$table['-127']['counter']),implode('  ',$iconsUnknownReason));

		$output.='<br /><h2>' . $LANG->getLL('stats_mails_returned') . '</h2>';
		$output.=tx_directmail_static::formatTable($tblLines,array('nowrap','nowrap align="right"',''),1,array(0,0,1), 'cellspacing="0" cellpadding="3" class="stats-table"');

			//Find all returned mail
		if (t3lib_div::_GP('returnList')||t3lib_div::_GP('returnDisable')||t3lib_div::_GP('returnCSV'))		{
			$res = $TYPO3_DB->exec_SELECTquery(
				'rid,rtbl',
				'sys_dmail_maillog',
				'mid='.intval($row['uid']).
					' AND response_type=-127'
				);
			$idLists = array();
			while($rrow = $TYPO3_DB->sql_fetch_assoc($res))	{
				switch($rrow['rtbl'])	{
					case 't':
						$idLists['tt_address'][]=$rrow['rid'];
					break;
					case 'f':
						$idLists['fe_users'][]=$rrow['rid'];
					break;
					default:
						$idLists[$rrow['rtbl']][]=$rrow['rid'];
					break;
				}
			}

			if (t3lib_div::_GP('returnList'))	{
				if (is_array($idLists['tt_address']))	{$output.='<br />' . $LANG->getLL('stats_emails') . '<br />' . tx_directmail_static::getRecordList(tx_directmail_static::fetchRecordsListValues($idLists['tt_address'],'tt_address'),'tt_address',$this->id,$this->doc->bgColor4);}
				if (is_array($idLists['fe_users']))		{$output.= '<br />' . $LANG->getLL('stats_website_users') . tx_directmail_static::getRecordList(tx_directmail_static::fetchRecordsListValues($idLists['fe_users'],'fe_users'),'fe_users',$this->id,$this->doc->bgColor4);}
			}
			if (t3lib_div::_GP('returnDisable'))	{
				if (is_array($idLists['tt_address']))	{
					$c=$this->disableRecipients(tx_directmail_static::fetchRecordsListValues($idLists['tt_address'],'tt_address'),'tt_address');
					$output.='<br />' . $c . ' ' . $LANG->getLL('stats_emails_disabled');
				}
				if (is_array($idLists['fe_users']))	{
					$c=$this->disableRecipients(tx_directmail_static::fetchRecordsListValues($idLists['fe_users'],'fe_users'),'fe_users');
					$output.='<br />' . $c . ' ' . $LANG->getLL('stats_website_users_disabled');
				}
			}
			if (t3lib_div::_GP('returnCSV'))	{
				$emails=array();
				if (is_array($idLists['tt_address']))	{
					$arr=tx_directmail_static::fetchRecordsListValues($idLists['tt_address'],'tt_address');
					foreach ($arr as $v) {
						$emails[]=$v['email'];
					}
				}
				if (is_array($idLists['fe_users']))	{
					$arr=tx_directmail_static::fetchRecordsListValues($idLists['fe_users'],'fe_users');
					foreach ($arr as $v) {
						$emails[]=$v['email'];
					}
				}
				$output.='<br />' . $LANG->getLL('stats_emails_returned_list') .  '<br />';
				$output.='<textarea'.$TBE_TEMPLATE->formWidthText().' rows="6" name="nothing">'.t3lib_div::formatForTextarea(implode(chr(10), $emails)).'
```

EDIT

Also hier wird der Link zusammengebaut:
'<a href="'.htmlspecialchars($url).'"><img '.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/zoom.gif', 'width="12" height="12"').' title="'.htmlspecialchars($url).'" /></a>';

---

Quelle: „Direct Mail - Link Respone - Verlinkung im Backend falsch“, typo3.net, https://www.typo3.net/d/102384-direct-mail-link-respone-verlinkung-im-backend-falsch
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
