[TYPO3-dev] XCLASS in CLI script

Jigal van Hemert jigal at xs4all.nl
Sun Jul 11 11:58:25 CEST 2010


Hi,

I'm struggling with a CLI script which contains an XCLASS of an existing 
class. It's about the dmailer class (which extends the t3lib_htmlmail 
class); this is part of direct_mail.

I XCLASSed this class with ux_dmailer. Among other custom functions this 
contains a custom version of getURL() which can now send POST variables 
to login as an fe_user to fetch the newsletter taking access restricted 
content into account.
When invoked from the Direct Mail backend module everything works fine. 
The XCLASS definitions in ext_localconf.php do their work.

When invoked by a cronjob this apparently doesn't work. So I copied the 
cron script cli_direct_mail.php and added some definitions to include 
the XCLASS'ed scripts:

function massSend(){

     // Check if cronjob is already running:
if (@file_exists (PATH_site.'typo3temp/tx_directmail_cron.lock')) {
     // If the lock is not older than 1 day, skip index creation:
     if (filemtime (PATH_site.'typo3temp/tx_directmail_cron.lock') > 
(time() - (60*60*24))) {
         die('TYPO3 Direct Mail Cron: Aborting, another process is 
already running!'.chr(10));
     } else {
         echo('TYPO3 Direct Mail Cron: A .lock file was found but it is 
older than 1 day! Processing mails ...'.chr(10));
     }
}

$lockfile = PATH_site.'typo3temp/tx_directmail_cron.lock';
touch ($lockfile);

require_once(PATH_t3lib.'class.t3lib_cs.php');
require_once(PATH_t3lib.'class.t3lib_htmlmail.php');

//*** EXTRA begin ***//
# XCLASS definitions
$GLOBALS['TYPO3_CONF_VARS']['BE']['XCLASS']['ext/direct_mail/res/scripts/class.dmailer.php'] 
= t3lib_extMgm::extPath('my_directmail') . 'class.ux_dmailer.php';
//*** EXTRA end ***//

require_once(t3lib_extMgm::extPath('direct_mail').'res/scripts/class.dmailer.php');

//*** EXTRA begin ***//
require_once(t3lib_extMgm::extPath('my_directmail') . 
'class.ux_dmailer.php');
//*** EXTRA end ***//

$htmlmail = t3lib_div::makeInstance('dmailer');
$htmlmail->start();
$htmlmail->runcron();
unlink ($lockfile);
}


The first extra block is a modified version of the XCLASS setting from 
ext_localconf, to make sure that class dmailer can see that there is an 
XCLASS defined.

The second extra block is added to make sure that the script get included.

Somehow this doesn't work. Any ideas how to make TYPO3 use the XCLASS'ed 
functions?

Thanks in advanced for helping these overheated brains :-)

-- 
Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh




More information about the TYPO3-dev mailing list