[TYPO3] Extension "comments" notification without the need to approve each comment?

Thomas Hirt info at thomas-hirt.at
Sun Sep 21 22:51:16 CEST 2008


Thanks! I am willing to learn!

What I did:

in ext_localconf.php I placed the following line:
-----------------------------------------------
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['comments']['processSubmission'] 
= 
'EXT:toms_extension/class.tx_tomsext_hookclass.php:tx_tomsext_hookclass->testEmail';
-----------------------------------------------

then I createted the file class.tx_tomsext_hookclass.php in 
ext/toms_extensions

There I copied the following lines (just to try if it would work). I 
copied them from the original Extension and they are in charge of 
sending the email. I thought this would send a second notification 
mail... of course it didn't.


<?php
class tx_tomsext_hookclass {
	function testEmail($uid, $points) {
		$toEmail = $this->conf['spamProtect.']['notificationEmail'];
		$fromEmail = $this->conf['spamProtect.']['fromEmail'];
		if (t3lib_div::validEmail($toEmail) && 
t3lib_div::validEmail($fromEmail)) {
			$template = 
$this->cObj->fileResource($this->conf['spamProtect.']['emailTemplate']);
			$check = md5($uid . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
			$markers = array(
				'###URL###' => t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),
				'###POINTS###' => $points,
				'###FIRSTNAME###' => $this->piVars['firstname'],
				'###LASTNAME###' => $this->piVars['lastname'],
				'###EMAIL###' => $this->piVars['email'],
				'###LOCATION###' => $this->piVars['location'],
				'###HOMEPAGE###' => $this->piVars['homepage'],
				'###CONTENT###' => $this->piVars['content'],
				'###REMOTE_ADDR###' => t3lib_div::getIndpEnv('REMOTE_ADDR'),
				'###APPROVE_LINK###' => 
t3lib_div::locationHeaderUrl('/index.php?eID=comments&uid=' . $uid . 
'&chk=' . $check . '&cmd=approve'),
				'###DELETE_LINK###' => 
t3lib_div::locationHeaderUrl('/index.php?eID=comments&uid=' . $uid . 
'&chk=' . $check . '&cmd=delete'),
				'###KILL_LINK###' => 
t3lib_div::locationHeaderUrl('/index.php?eID=comments&uid=' . $uid . 
'&chk=' . $check . '&cmd=kill'),
				'###SITE_REL_PATH###' => t3lib_extMgm::siteRelPath('comments'),
			);
			// Call hook for custom markers
			if 
(is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['comments']['sendNotificationMail'])) 
{
			 
foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['comments']['sendNotificationMail'] 
as $userFunc) {
					$params = array(
						'pObj' => &$this,
						'template' => $template,
						'check' => $check,
						'markers' => $markers,
					);
					if (is_array($tempMarkers = t3lib_div::callUserFunction($userFunc, 
$params, $this))) {
						$markers = $tempMarkers;
					}
				}
			}
			$content = $this->cObj->substituteMarkerArray($template, $markers);
			t3lib_div::plainMailEncoded($toEmail, 
$this->pi_getLL('email.subject'), $content, 'From: ' . 
$this->conf['spamProtect.']['fromEmail']);
		}
	}
}
?>

Could someone give me a hint?
Thanks,
Thomas



Søren Malling schrieb:
> Else, try to have a look at the comments from Dmitry, which he gave me while
> i was working on a hook
> 
> http://support.typo3.org/general/english/m/re-typo3-connecting-comments-extension-to-fe-users-348886/
> 
> and maybe look at the final plugin (completed by Martin Weissen)
> 
> http://typo3.org/extensions/repository/view/comments_feuser/current/
> 
> And get the "feeling" with working with hooks :)
> 
> Regards,
> 
> Søren
> 
> On Sun, Sep 21, 2008 at 4:29 PM, Francois Suter <fsuter at cobweb.ch> wrote:
> 
>> Hi,
>>
>>> So if someone could explain me how use a hook, I would be very glad...
>> There's a full chapter on hooks in the Core APIs doc:
>>
>>
>> http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.1.0/view/3/4/
>>
>> HTH
>>
>> --
>>
>> Francois Suter
>> Cobweb Development Sarl - http://www.cobweb.ch
>> _______________________________________________
>> TYPO3-english mailing list
>> TYPO3-english at lists.netfielders.de
>> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
>>


More information about the TYPO3-english mailing list