示例#1
0
 /**
  * Send a set of notifications
  *
  * @param ComNotificationsDomainEntityNotification $notification Notification
  *
  * @return void
  */
 public function sendNotification($notification)
 {
     $people = $this->getService('repos://site/actors.actor')->getQuery(true)->id($notification->subscriberIds->toArray())->fetchSet();
     $settings = $this->getService('repos://site/notifications.setting')->getQuery(true, array('actor.id' => $notification->target->id))->fetchSet();
     $settings = AnHelperArray::indexBy($settings, 'person.id');
     $mails = $this->_renderMails(array('notification' => $notification, 'people' => $people, 'settings' => $settings));
     $debug = $this->getBehavior('mailer')->getTestOptions()->enabled;
     if ($debug) {
         $recipients = array();
         foreach ($mails as $i => $mail) {
             $recipients[] = $mail['to'];
             if ($i < 3) {
                 $body = array();
                 $body[] = 'Subject   : ' . $mail['subject'];
                 $body[] = $mail['body'];
                 $body = implode('<br />', $body);
                 $bodies[] = $body;
             }
         }
         $bodies[] = 'Sending out ' . count($mails) . ' notification mail(s)';
         $bodies[] = '<br /><br />' . implode('<br />', $recipients);
         $mails = array(array('subject' => $notification->name, 'body' => implode('<hr />', $bodies)));
     }
     foreach ($mails as $mail) {
         $this->mail($mail);
     }
 }
示例#2
0
 /**
  * Loads all the necessary objects after each collection fetch.
  * 
  * @param AnDomainEntityset $stories
  */
 protected function _preloadData($stories)
 {
     $node_ids = array();
     $comment_ids = array();
     foreach ($stories as $story) {
         $columns = $story->getRowData();
         $node_ids = array_merge($node_ids, $story->getIds('owner'), $story->getIds('subject'), $story->getIds('target'), $story->getIds('object'));
         $comment_ids = array_merge($comment_ids, $story->getIds('comment'));
     }
     $node_ids = array_unique($node_ids);
     $query = $this->getService('repos://site/base.comment')->getQuery()->where('parent.id', 'IN', $node_ids);
     $author_ids = $query->fetchValues('author.id');
     $node_ids = array_unique(array_merge($node_ids, $author_ids, $comment_ids));
     //we don't any behavior messes around with the fetched stories
     $query = $this->getService('repos://site/base.node')->getQuery()->id($node_ids)->disableChain();
     $query->columns('*');
     $nodes = $query->fetchSet();
     $nodes = AnHelperArray::indexBy($nodes, 'id');
     $this->_loaded_nodes = $nodes;
 }