Skip to content

Commit

Permalink
[user] add delegate points before xoopsmailer->send() with xoopsmailer
Browse files Browse the repository at this point in the history
- 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 459d420
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions html/modules/user/actions/LostPassAction.class.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions html/modules/user/actions/UserActivateAction.class.php
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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'
Expand All @@ -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();
}
}
Expand Down

0 comments on commit 459d420

Please sign in to comment.