* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBEvent_Handler' , 'WBEvent_Handler_ITS' , 'WBEvent_Handler_Mail' , 'patI18n'); /** * WBEvent_Handler_ITS_MailCustomer * * Send e-mail to customer * * @version 1.0.0 * @package Wombat * @subpackage base */ class WBEvent_Handler_ITS_MailCustomer extends WBEvent_Handler_ITS { /** * Handler config * * For parameter list see parent class, additional parameter: * - loadticket: index of id to load ticket * * @see WBEvent_Handler_Mail * @var array */ protected $config = array( 'from' => '', 'fromindex' => '', 'rcpt' => '', 'rcptindex' => 'email', 'addrcpt' => '', 'lang' => '', 'langindex' => '', 'tmpl' => 'email', 'loadticket' => '' ); /** * User object * @var WBUser */ private $user; /** * @var WBDictionary_URL */ private $dict; /** * actually send e-mails * @var WBEvent_Handler_Mail */ private $mail; /** * Process event * * Send e-mail to customer * - Load ticket data using id given in event data * - Add ticket data to event data * - Use e-mail-address from "customeremailurlid" as primary rcpt address * - Load e-mail-address from user, if customer is user * - Send to customer's e-mail-address if it is not the same * * @param WBEvent $e * @return bool true to continue, false to stop processing * @throws Exception in case of error */ public function process(WBEvent $e) { $this->loadTicket($e); $data = $e->get(); $data['status_display'] = patI18n::dgettext('wombat', 'its_status_' . $data['status']); $this->mail = WBClass::create('WBEvent_Handler_Mail'); // find first rcpt $rcpt = ''; if (!empty($data['customeremailurlid'])) { $this->dict = WBClass::create('WBDictionary_URL'); $this->dict->load($data['customeremailurlid']); $rcpt = $this->dict->getWord(); if (!empty($rcpt)) { $this->config['rcpt'] = $rcpt; $this->mail->setConfig($this->config); $this->mail->process($e); } } // find second rcpt if (empty($data['customeruid'])) { return true; } $this->user = WBClass::create('WBUser'); if (!$this->user->load($data['customeruid'])) { return true; } $user = $this->user->getData(); // don't send to the same address twice if ($rcpt == $user['email']) { return true; } $this->config['rcpt'] = $user['email']; $this->config['lang'] = $user['lang']; $this->mail->setConfig($this->config); $this->mail->process($e); return true; } }