Permalink
Browse files

[user] add delegate points before xoopsmailer->send() with `xoopsmailer`

- sample preload (html/preload/UserPreSendMail.class.php)
```php
<?php

class UserPreSendMail extends XCube_ActionFilter
{
	function postFilter() {
		$this->mRoot->mDelegateManager->add('Legacy.Event.RegistUser.SendMail'
, array($this ,'preSendMail'));
	}
	
	function preSendMail(&$mailer, $action) {

		/* COMMON PROCESS */
		
		/* EDIT SUBJECT */
		//$subject = $mailer->getVar('subject');
		//$mailer->setSubject('['.$action.'] ' . $subject);

		/* CHANGE MAIL FROM */
		//$mailer->setFromEmail('example@example.com');
		//$mailer->setFromName('XOOPS Cube Legacy Site');


		/* PROCESS OF EACH ACTION */

		switch($action) {
			case 'LostPass1' :
				break;
			case 'LostPass2' :
				break;
			case 'Activated' :
				break;
			case 'Register' :
				/* CHANGE TEMPLATE */
				//$mailer->setTemplate('register_custom.tpl');
				break;
			case 'AdminActivate' :
				break;
			case 'Notify' :
				break;
		}
	}
}
```
  • Loading branch information...
nao-pon committed Jul 5, 2014
1 parent aa33f6a commit 459d4206383b447b2fc36505cd6e7a024891acaa
@@ -74,6 +74,7 @@ function _updatePassword(&$controller) {
$director =new User_LostPassMailDirector($builder, $lostUser, $controller->mRoot->mContext->getXoopsConfig(), $extraVars);
$director->contruct();
$xoopsMailer =& $builder->getResult();
XCube_DelegateUtils::call('Legacy.Event.RegistUser.SendMail', new XCube_Ref($xoopsMailer), 'LostPass2');
if (!$xoopsMailer->send()) {
// $xoopsMailer->getErrors();
return USER_FRAME_VIEW_ERROR;
@@ -107,6 +108,7 @@ function execute(&$controller, &$xoopsUser)
$director =new User_LostPassMailDirector($builder, $lostUser, $controller->mRoot->mContext->getXoopsConfig());
$director->contruct();
$xoopsMailer =& $builder->getResult();
XCube_DelegateUtils::call('Legacy.Event.RegistUser.SendMail', new XCube_Ref($xoopsMailer), 'LostPass1');
if (!$xoopsMailer->send()) {
// $xoopsMailer->getErrors();
@@ -66,6 +66,7 @@ function getDefaultView(&$controller, &$xoopsUser)
$director =new User_UserRegistMailDirector($builder, $this->mObject, $controller->mRoot->mContext->getXoopsConfig(), $this->mConfig);
$director->contruct();
$mailer=&$builder->getResult();
XCube_DelegateUtils::call('Legacy.Event.RegistUser.SendMail', new XCube_Ref($mailer), 'Activated');
if ($mailer->send()) {
$controller->executeRedirect(XOOPS_URL . '/', 5, sprintf(_MD_USER_MESSAGE_ACTVMAILOK, $this->mObject->get('uname')));
} else {
@@ -114,6 +114,7 @@ function _processMail(&$controller)
$director =new User_UserRegistMailDirector($builder, $this->mNewUser, $controller->mRoot->mContext->getXoopsConfig(), $this->mConfig);
$director->contruct();
$mailer =& $builder->getResult();
XCube_DelegateUtils::call('Legacy.Event.RegistUser.SendMail', new XCube_Ref($mailer), ($activationType == 0)? 'Register' : 'AdminActivate');
if (!$mailer->send()) {
} // TODO CHECKS and use '_MD_USER_ERROR_YOURREGMAILNG'
@@ -126,6 +127,7 @@ function _eventNotifyMail(&$controller)
$director =new User_UserRegistMailDirector($builder, $this->mNewUser, $controller->mRoot->mContext->getXoopsConfig(), $this->mConfig);
$director->contruct();
$mailer =& $builder->getResult();
XCube_DelegateUtils::call('Legacy.Event.RegistUser.SendMail', new XCube_Ref($mailer), 'Notify');
$mailer->send();
}
}

0 comments on commit 459d420

Please sign in to comment.