Exemple #1
0
 /** Add a new help request message and send email to Scheme in box.
  */
 public function addRequest($data)
 {
     if (!empty($data['csrf'])) {
         unset($data['csrf']);
     }
     if (empty($data['comment_date'])) {
         $data['comment_date'] = $this->timeCreation();
     }
     if (empty($data['updatedBy'])) {
         $data['updatedBy'] = $this->userNumber();
     }
     if ($this->_akismet->isSpam($data)) {
         $data['comment_approved'] = self::SPAM;
     } else {
         $data['comment_approved'] = self::NOTSPAM;
     }
     $mail = new Zend_Mail();
     $mail->setBodyText('You submitted this comment/ query: ' . strip_tags($data['comment_content']));
     $mail->setFrom($data['comment_author_email'], $data['comment_author']);
     $mail->addTo('*****@*****.**', 'The Portable Antiquities Scheme');
     $mail->addCC($data['comment_author_email'], $data['comment_author']);
     $mail->setSubject('Contact us submission');
     $mail->send();
     return parent::insert($data);
 }
 /** 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/');
     }
 }
 /** Provide a notification for an object
  */
 protected function notify($objecttype, $broadperiod, $data)
 {
     $findData = (object) $data;
     $finds = new Users();
     $owner = $finds->getOwner($findData->comment_findID);
     $advisers = $this->getAdviser($objecttype, $broadperiod);
     $mail = new Zend_Mail('UTF-8');
     $mail->setFrom('*****@*****.**', 'The Portable Antiquities Scheme error reporter');
     $mail->setSubject('Error report submitted on record id number : ' . $owner['0']['old_findID']);
     foreach ($advisers as $k => $v) {
         $mail->addCC($v, $k);
     }
     $message = '';
     $message .= $findData->comment_author;
     $message .= ' submitted an error report type: ' . $findData->comment_type;
     $message .= "\n";
     $message .= 'Copied to Finds Adviser(s) in case action is required.';
     $message .= "\n";
     $message .= strip_tags(nl2br($findData->comment_content));
     $message .= "\n";
     $message .= 'Error report on http://www.finds.org.uk/database/artefacts/record/id/' . $findData->comment_findID;
     $message .= "\n";
     $message .= 'Object type: ' . $owner['0']['objecttype'];
     $message .= "\n";
     $message .= 'Broadperiod: ' . $owner['0']['broadperiod'];
     $message .= "\n";
     $message .= 'Thank you for taking the time to submit an error to us. We appreciate that you have taken the time to improve our database';
     $mail->addCC($findData->comment_author_email, $findData->comment_author);
     $mail->addTo($owner['0']['email'], $owner['0']['fullname']);
     $mail->setBodyText($message);
     $mail->send();
 }