Hi, 

several times we had projects where one of the requirements was to trigger some 
special functionality before sending an email from oxemail class. Especially if 
this special functionality is dependent on the type of email - it is quite 
cumberesome to solve this, cause in the _sendMail() function you do not know 
which type of email has to be sent. 

So I would like to have a property which is filled by the name of the function 
which has been called before, like this: 

$_sActMailFunctionCall = ""; 

public function sendOrderEmailToOwner( $sOrder, $sSubject = null ) 
{ 
$this->_sActMailFunctionCall = "sendOrderEmailToOwner"; 
... 
} 

Of course you could even build a small sort of factory function which would be 
called by the several view classes, doing this job - so you would not have to 
put a new line of coude into each mail function - like this for example: 

in class oxEmail: 

public function executeSendMailFunction( $sFunction, $aParams ) 
{ 
$this->_sActMailFunctionCall = $sFunction; 
$this->$sFunction( $aParams); 
} 

in oxOrder::_sendOrderByEmail(): 

$oxEmail->executeSendMailFunction( "sendOrderEmailToOwner", $aParams ); 

Doing this would give developers a whole bunch of nice possibilities. For 
example you could write a central function to manipulate email subjects 
dependent on the type of email. Or you could save the content of special email 
and so on ... 
At the moment all this is possible - but you have to overload a lot of 
functions for this to detect the type of email. 

Using the factory function would mean that the several send-functions would not 
have to be changed appart from the parameters given to them. But even this 
could be done inside the factory, which then would have to prepare the params 
for the single calls. 

The "factory way" in my opinion would be the best one regarding code layout, 
but I see that in terms of compatibility to old versions and modules this could 
cause some trouble .. - So perhaps as a first step you could just add the first 
mentioned line of could to each function? 

If somebody has got a better idea to solve this - let me know! 

Regards, 
Andreas 

-- 
anzido GmbH 
Kirchhörder Str. 12 
44229 Dortmund 
Tel.: 0231 - 60 71 079 
Fax.: 0231 - 60 71 081 
Mobil:0176 - 8325 1488 
Email: i...@anzido.com 
Web: http://www.anzido.com ( http://www.anzido.com/ ) 

USt-ID: DE257982972 
Geschäftsführung: Andreas Ziethen 
Amtsgericht Dortmund HRB 20883
_______________________________________________
dev-general mailing list
dev-general@lists.oxidforge.org
http://dir.gmane.org/gmane.comp.php.oxid.general

Reply via email to