/**
  * Send message to author of given classified
  *
  * @param Announcement $classified Announcement
  * @param array        $params     Extra parameters to compose message
  *
  * @return void
  */
 public function sendMessageToAuthor(Announcement $classified, $params = array())
 {
     $emailService = $this->container->get('email');
     $em = $this->container->get('em');
     $templatesService = $this->container->get('newscoop.templates.service');
     $placeholdersService = $this->container->get('newscoop.placeholders.service');
     $preferencesService = $this->container->get('preferences');
     $smarty = $templatesService->getSmarty();
     $user = $em->getRepository('Newscoop\\Entity\\User')->findOneById($classified->getUser()->getNewscoopUserId());
     $smarty->assign('user', new \MetaUser($user));
     $smarty->assign('announcement', $classified);
     $smarty->assign('params', $params);
     try {
         $message = $templatesService->fetchTemplate("_ahs_adverts/email_classified_contact.tpl");
     } catch (\Exception $e) {
         throw new NotFoundHttpException("Could not load template: _ahs_adverts/email_classified_contact.tpl");
     }
     $emailService->send($placeholdersService->get('subject'), $message, $user->getEmail(), array($preferencesService->AdvertsNotificationEmail));
 }
 /**
  * Process single ad
  *
  * @param Announcement $ad         Announcement
  * @param Zend_Router  $zendRouter Zend Router
  *
  * @return array
  */
 private function processAd(Announcement $ad, $zendRouter)
 {
     $em = $this->get('em');
     $user = $em->getRepository('Newscoop\\Entity\\User')->findOneBy(array('id' => $ad->getUser()->getNewscoopUserId()));
     $image = $ad->getFirstImage();
     return array('id' => $ad->getId(), 'name' => $ad->getName(), 'thumbnailUrl' => $image['thumbnailUrl'], 'description' => $ad->getDescription(), 'publication' => $ad->getPublication()->getName(), 'price' => $ad->getPrice(), 'reads' => $ad->getReads(), 'username' => array('href' => $zendRouter->assemble(array('module' => 'admin', 'controller' => 'user', 'action' => 'edit', 'user' => $user->getId()), 'default', true), 'username' => $user->getUsername()), 'created' => $ad->getCreatedAt(), 'valid_to' => $ad->getValidTo(), 'status' => $ad->getIsActive(), 'links' => array(array('rel' => 'edit', 'href' => ""), array('rel' => 'activate', 'href' => $this->generateUrl('ahs_advertsplugin_admin_activate', array('id' => $ad->getId()))), array('rel' => 'deactivate', 'href' => $this->generateUrl('ahs_advertsplugin_admin_deactivate', array('id' => $ad->getId()))), array('rel' => 'delete', 'href' => "")));
 }