public function processForm($form) { $data = $form->getValues(); if ($data['form_id'] != $this->_formDefinition->form_id) { throw new FFR_Model_Exception('The form does NOT match the definition'); } if ($this->_formDefinition->form_save_db == 1) { $submissionGateway = new Forms_Model_SubmissionGateway(); $submission = $submissionGateway->create($data); $submission->save($this->_formDefinition); } if ($this->_formDefinition->form_send_notification == 1) { $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); if (null === $viewRenderer->view) { $viewRenderer->initView(); } $view = $viewRenderer->view; $path = APPLICATION_PATH . '/modules/forms/views/scripts/'; $view->addScriptPath($path); $view->formData = $data; $view->formDefinition = $this->_formDefinition->toArray(); $serviceFinder = Zend_Controller_Action_HelperBroker::getStaticHelper('service'); $settingService = $serviceFinder->getService('setting', 'settings'); $url = parse_url($settingService->fetchSetting('site_url')); $host = explode('.', $url['host']); // Shift element off the front if we have www if (count($host) > 2) { array_shift($host); } $mail = new Zend_Mail(); $mail->setFrom('no-reply@' . implode('.', $host), $this->_formDefinition->form_name . ' Form Submission'); $mail->setBodyHtml($view->render('helpers/_customFormEmail.phtml')); // Add all the notifications foreach ($this->_formDefinition->formNotifications as $email) { $mail->addTo($email['form_notification_email'], $email['form_notification_name']); } $mail->setSubject($this->_formDefinition->form_name . ' Form Submission'); $mail->send(); } return true; }
protected function _primeCache($id) { $submissionGateway = new Forms_Model_SubmissionGateway(); $submissionGateway->fetchSubmission($id); }