Exemplo n.º 1
0
 /** Email a search result
  * @access public
  * @return void
  */
 public function emailAction()
 {
     $user = $this->_helper->identity->getPerson();
     // Clean up the parameters that are to be parsed.
     $params = $this->cleanParams($this->getAllParams(), array('searchDescription', 'public', 'title', 'fullname', 'email', 'messageToUser'));
     $this->view->params = $params;
     $form = new EmailSearchForm();
     $this->view->form = $form;
     if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
         $to[] = array('email' => $form->getValue('email'), 'name' => $form->getValue('fullname'));
         $from[] = array('email' => $user->email, 'name' => $user->fullname);
         $url = array('url' => $params);
         $assignData = array_merge($form->getValues(), $from[0], $url);
         $this->_helper->mailer($assignData, 'sendSearch', $to, null, $from);
         $this->getFlash()->addMessage('Your email has been sent to ' . $form->getValue('fullname'));
         $this->_helper->Redirector->gotoSimple('results', 'search', 'database', $params);
     } else {
         $form->populate($params);
     }
 }
Exemplo n.º 2
0
 /** Email a search result
  */
 public function emailAction()
 {
     $user = $this->getAccount();
     $this->view->headTitle('Email this search to another person');
     $searches = new Searches();
     $lastsearch = $searches->fetchRow($searches->select()->where('userid = ?', $this->getIdentityForForms())->order('id DESC'));
     if (count($lastsearch)) {
         $querystring = unserialize($lastsearch->searchString);
         $params = array();
         $query = '';
         foreach ($querystring as $key => $value) {
             $query .= $key . '/' . $value . '/';
             $params[$key] = $value;
         }
         $this->view->params = $params;
         $form = new EmailSearchForm();
         $this->view->form = $form;
         if ($this->_request->isPost()) {
             $data = $this->_getAllParams();
             if ($form->isValid($data)) {
                 $sender = $user->fullname;
                 $senderemail = $user->email;
                 $recipient = $form->getValue('fullname');
                 $recipientemail = $form->getValue('email');
                 $message = $form->getValue('messageToUser');
                 $strippedmessage = strip_tags($message);
                 $url = 'http://' . $_SERVER['SERVER_NAME'] . '/database/search/results/' . $query;
                 $mail = new Zend_Mail();
                 $mail->addHeader('X-MailGenerator', 'The Portable Antiquities Scheme\'s awesome database');
                 $mail->setBodyHtml('<p>Dear ' . $recipient . '</p>' . $message . '<p>Located at this url:  ' . $url . '</p><p>From ' . $sender . '</p>');
                 $mail->setFrom('*****@*****.**', 'The Portable Antiquities Scheme');
                 $mail->setBodyText('Dear ' . $recipient . ',' . $message . ' ' . $url . 'From,' . $sender);
                 $mail->addTo($recipientemail, $recipient);
                 $mail->addCC($senderemail, $sender);
                 $mail->setSubject('I thought you might be interested in this search on the PAS Database.');
                 $mail->send();
                 $this->_flashMessenger->addMessage('Your email has been sent to ' . $recipient . '. Thank you for sending them some of our records.');
                 $this->_redirect('/database/search/results/' . $query);
             } else {
                 $form->populate($data);
             }
         }
     } else {
         $this->_flashMessenger->addMessage('You haven\'t ever searched, so you have nothing to email!');
         $this->_redirect('/database/search/');
     }
 }