Example #1
0
 /**
  * Renders emails for a list of people
  *
  * @param array $config Config parameter
  *
  * @return array
  */
 protected function _renderMails($config)
 {
     $mails = array();
     $config = new KConfig($config);
     $settings = $config->settings;
     $people = $config->people;
     $notification = $config->notification;
     foreach ($people as $person) {
         $setting = $settings->{$person->id};
         if (!($ret = $notification->shouldNotify($person, $setting))) {
             $notification->removeSubscribers($person);
             continue;
         }
         $person->addNotification($notification);
         if ($ret !== ComNotificationsDomainDelegateSettingInterface::NOTIFY_WITH_EMAIL) {
             continue;
         }
         //since each owner revieces the mail, they are in fact the viewer
         //so we need to set the as viewer while processing the notification
         KService::set('com:people.viewer', $person);
         $notification->owner = $person;
         $data = new KConfig($this->_parser->parse($notification));
         $data->append(array('email_subject' => $data->title, 'email_title' => pick($data->email_subject, $data->title), 'email_body' => $data->body, 'notification' => $notification));
         if ($notification->target && !$notification->target->eql($person)) {
             $data->commands->insert('notification_setting', array('actor' => $notification->target));
         }
         $body = $this->renderMail(array('layout' => false, 'template' => 'notification', 'data' => array('person' => $person, 'commands' => $data->commands, 'subject' => $notification->subject, 'title' => $data->email_title, 'body' => $data->email_body)));
         $mails[] = array('subject' => $data->email_subject, 'body' => $body, 'to' => $person->email);
     }
     return $mails;
 }
Example #2
0
 /**
  * Initializes the default configuration for the object.
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  */
 protected function _initialize(KConfig $config)
 {
     $config->append(array('filters' => array('com://site/notifications.template.filter.blockquote', 'com://site/notifications.template.filter.link')));
     parent::_initialize($config);
 }