* @license PHP License * @package Wombat * @subpackage base */ WBClass::load('WBEvent_Handler' , 'WBEvent_Handler_User_Mail' ); /** * Event_Handler_User_Mail_Group * * Send an e-mail to multiple users * * @version 0.1.0 * @package Wombat * @subpackage base */ class WBEvent_Handler_User_Mail_Group extends WBEvent_Handler_User_Mail { /** * Handler config * * Parameters * - "from" e-mail address in from header * - "fromindex" load e-mail address for from header form index * - "addrcpt" list of additional rcpts * - "lang" locale settings * - "langindex" index for locale settings * - "tmpl" template for mail body * - "gid" user group to collect e-mail addresses from * - "uid" user id (or list of) to collect e-mail addresse(s) from * * @var array */ protected $config = array( 'rcpt' => '', 'rcptindex' => 'rcpt_email', 'from' => '', 'fromindex' => '', 'addrcpt' => '', 'lang' => '', 'langindex' => '', 'tmpl' => 'email', 'gid' => '', 'gidindex' => '' ); /** * Send E-Mails * * Collect users by uids and e-mails to all addresses. * Add users' data to event data, prefixed by "rcpt_" * * @param WBEvent $e * @return bool true to continue, false to stop processing * @throws Exception in case of error */ public function process(WBEvent $e) { $gid = $this->config['gid']; if (empty($uid) && !empty($this->config['gidindex'])) { $gid = $e->get($this->config['gidindex']); } /** @var WBUser_Storage */ $storage = WBClass::create('WBUser')->getStorageModule(); $uid = $storage->getIdByGroupId($gid); if (empty($uid)) { return true; } if (!is_array($uid)) { $uid = array($uid); } $this->mail2UserList($e, $uid); return true; } }