1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
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: 20: 21: 22: 23: 24: 25: 26: 27: 28:
29: class MailedFormProcessor extends DefaultFormProcessor {
30:
31: 32: 33: 34: 35: 36: 37: 38:
39: protected function _processStoredData() {
40:
41:
42: $errors = array();
43:
44:
45: $values = $this->getForm()->getValues();
46:
47:
48: try {
49:
50: $tpl = cSmartyFrontend::getInstance(true);
51: $tpl->assign('values', $values);
52: $subject = $tpl->fetch('eval:' . $this->getModule()->getSetting('pifaform_mail_client_subject'));
53:
54: $tpl = cSmartyFrontend::getInstance(true);
55: $tpl->assign('values', $values);
56: $body = $tpl->fetchGeneral($this->getModule()->getSetting('pifaform_mail_client_template'));
57:
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[] = mi18n("PIFA_CLIENT_MAIL") . ": " . $e->getMessage();
68: }
69:
70:
71: try {
72:
73: $tpl = cSmartyFrontend::getInstance(true);
74: $tpl->assign('values', $values);
75: $subject = $tpl->fetch('eval:' . $this->getModule()->getSetting('pifaform_mail_system_subject'));
76:
77: $tpl = cSmartyFrontend::getInstance(true);
78: $tpl->assign('values', $values);
79: $body = $tpl->fetchGeneral($this->getModule()->getSetting('pifaform_mail_system_template'));
80:
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[] = mi18n("PIFA_SYSTEM_MAIL") . ": " . $e->getMessage();
93: }
94:
95:
96: if (0 < count($errors)) {
97: throw new PifaMailException(implode('<br>', $errors));
98: }
99: }
100:
101: 102: 103: 104: 105: 106:
107: protected function _getAttachmentNames() {
108:
109:
110:
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: 132: 133: 134: 135:
136: protected function _getAttachmentStrings() {
137: return array();
138: }
139: }
140:
141: ?>