Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cContentTypePifaForm
  • DefaultFormModule
  • DefaultFormProcessor
  • ExampleOptionsDatasource
  • MailedFormProcessor
  • Pifa
  • PifaAbstractFormModule
  • PifaAbstractFormProcessor
  • PifaAjaxHandler
  • PifaExporter
  • PifaExternalOptionsDatasourceInterface
  • PifaField
  • PifaFieldCollection
  • PifaForm
  • PifaFormCollection
  • PifaImporter
  • PifaLeftBottomPage
  • PifaRightBottomFormDataPage
  • PifaRightBottomFormExportPage
  • PifaRightBottomFormFieldsPage
  • PifaRightBottomFormImportPage
  • PifaRightBottomFormPage
  • SolrRightBottomPage

Exceptions

  • PifaDatabaseException
  • PifaException
  • PifaIllegalStateException
  • PifaMailException
  • PifaNotImplementedException
  • PifaNotYetStoredException
  • PifaValidationException
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  *
  5:  * @package Plugin
  6:  * @subpackage FormAssistant
  7:  * @version SVN Revision $Rev:$
  8:  * @author marcus.gnass
  9:  * @copyright four for business AG
 10:  * @link http://www.4fb.de
 11:  */
 12: 
 13: // assert CONTENIDO framework
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: plugin_include(Pifa::getName(), 'extensions/class.pifa.default_form_processor.php');
 17: 
 18: /**
 19:  * The given data should be send via email to the systems mail address and a
 20:  * confirmation mail to the user itself.
 21:  * This feature can be accomplished by extending the class
 22:  * PifaFormAbstractProcessor and implementing its method _processStoredData().
 23:  *
 24:  * Any uploads of the given form will be added as attachments to the system
 25:  * mail.
 26:  *
 27:  * @author marcus.gnass
 28:  */
 29: class MailedFormProcessor extends DefaultFormProcessor {
 30: 
 31:     /**
 32:      * Sends client & system mail independantly.
 33:      * If an error occurs on sending the first mail the second mail is sent
 34:      * nonetheless.
 35:      *
 36:      * @see DefaultFormProcessor::_processStoredData()
 37:      * @throws PifaMailException if any mail could not be sent
 38:      */
 39:     protected function _processStoredData() {
 40: 
 41:         // array to collect errors
 42:         $errors = array();
 43: 
 44:         // get values
 45:         $values = $this->getForm()->getValues();
 46: 
 47:         // client mail
 48:         try {
 49:             // get subject from template
 50:             $tpl = cSmartyFrontend::getInstance(true);
 51:             $tpl->assign('values', $values);
 52:             $subject = $tpl->fetch('eval:' . $this->getModule()->getSetting('pifaform_mail_client_subject'));
 53:             // get body from template
 54:             $tpl = cSmartyFrontend::getInstance(true);
 55:             $tpl->assign('values', $values);
 56:             $body = $tpl->fetchGeneral($this->getModule()->getSetting('pifaform_mail_client_template'));
 57:             // send mail
 58:             $this->getForm()->toMailRecipient(array(
 59:                 'from' => $this->getModule()->getSetting('pifaform_mail_client_from_email'),
 60:                 'fromName' => $this->getModule()->getSetting('pifaform_mail_client_from_name'),
 61:                 'to' => $values['email'],
 62:                 'subject' => $subject,
 63:                 'body' => $body,
 64:                 'charSet' => 'UTF-8'
 65:             ));
 66:         } catch (PifaMailException $e) {
 67:             $errors[] = 'client mail could not be sent: ' . $e->getMessage();
 68:         }
 69: 
 70:         // system mail
 71:         try {
 72:             // get subject from template
 73:             $tpl = cSmartyFrontend::getInstance(true);
 74:             $tpl->assign('values', $values);
 75:             $subject = $tpl->fetch('eval:' . $this->getModule()->getSetting('pifaform_mail_system_subject'));
 76:             // get body from template
 77:             $tpl = cSmartyFrontend::getInstance(true);
 78:             $tpl->assign('values', $values);
 79:             $body = $tpl->fetchGeneral($this->getModule()->getSetting('pifaform_mail_system_template'));
 80:             // send mail
 81:             $this->getForm()->toMailRecipient(array(
 82:                 'from' => $this->getModule()->getSetting('pifaform_mail_system_from_email'),
 83:                 'fromName' => $this->getModule()->getSetting('pifaform_mail_system_from_name'),
 84:                 'to' => $this->getModule()->getSetting('pifaform_mail_system_recipient_email'),
 85:                 'subject' => $subject,
 86:                 'body' => $body,
 87:                 'attachmentNames' => $this->_getAttachmentNames(),
 88:                 'attachmentStrings' => $this->_getAttachmentStrings(),
 89:                 'charSet' => 'UTF-8'
 90:             ));
 91:         } catch (PifaMailException $e) {
 92:             $errors[] = 'system mail could not be sent: ' . $e->getMessage();
 93:         }
 94: 
 95:         // throw errors
 96:         if (0 < count($errors)) {
 97:             throw new PifaMailException(implode('<br>', $errors));
 98:         }
 99:     }
100: 
101:     /**
102:      * Return all files that were uploaded by the form as names of attachments
103:      * to be added to the system mail.
104:      *
105:      * @return array
106:      */
107:     protected function _getAttachmentNames() {
108: 
109:         // determine attachment names
110:         // these are already stored in the FS
111:         $attachmentNames = array();
112:         if (0 < count($this->getForm()->getFiles())) {
113:             $tableName = $this->getForm()->get('data_table');
114:             $lastInsertedId = $this->getForm()->getLastInsertedId();
115:             $cfg = cRegistry::getConfig();
116:             $destPath = $cfg['path']['contenido_cache'] . 'form_assistant/';
117:             foreach ($this->getForm()->getFiles() as $column => $file) {
118:                 if (!is_array($file)) {
119:                     continue;
120:                 }
121:                 $destName = $tableName . '_' . $lastInsertedId . '_' . $column;
122:                 $destName = preg_replace('/[^a-z0-9_]+/i', '_', $destName);
123:                 $attachmentNames[$column] = $destPath . $destName;
124:             }
125:         }
126: 
127:         return $attachmentNames;
128:     }
129: 
130:     /**
131:      * Returns an empty array cause there are no attachments that will be
132:      * created on the fly.
133:      *
134:      * @return array
135:      */
136:     protected function _getAttachmentStrings() {
137:         return array();
138:     }
139: }
140: 
141: ?>
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0