} $doc->addScript(JURI::root() . 'modules/mod_simpleform2/ajax/jquery.form.js'); $doc->addScript(JURI::root() . 'modules/mod_simpleform2/ajax/jquery.simpleform.js'); } $doc->addScriptDeclaration($script); } defined('SIMPLEFORM2') or define('SIMPLEFORM2', 1); $task = JRequest::getCmd('task'); $post = (array) JRequest::get('post'); $moduleID = (int) JRequest::getInt('moduleID'); $form = new simpleForm2(); $form->set('id', $id); $form->set('moduleID', $module->id); $form->set('_key', $params->get('domainKey', '')); $form->parse($params->get('simpleCode', '')); if ($task == 'sendForm' && count($post) > 0 && $moduleID == (int) $module->id) { $form->set('defaultError', JText::_('Enter value for')); $result = $form->processRequest($post); if ($result !== false) { $ok = $form->sendEmail($result, $params); if ($ok) { echo $params->get('okText', JText::_('Form succeed')); return true; } else { echo '<script type="text/javascript">jQuery(document).ready(function(){alert("' . $form->getError() . '");});</script>'; } } else { echo '<script type="text/javascript">jQuery(document).ready(function(){alert("' . $form->getError() . '");});</script>'; } } $form->render();
} } } else { $recieps[] = $mailTo; } foreach ($recieps as $reciep) { $mail->addRecipient($reciep); } $mail->addCC(null); $mail->addBCC(null); foreach ($form->attachments as $attachment) { $mail->AddStringAttachment(file_get_contents($attachment->file), $attachment->name); } $ok = $mail->Send(); if (is_object($ok)) { sfEcho('!' . $ok->message); } else { $okMSG = $params->get('okText', JText::_('Form succeed')); sfEcho('=' . $okMSG); } } else { sfEcho('!' . $form->getError()); } break; } function sfEcho($txt) { header('Content-type: text/html; charset="utf-8"', true); echo $txt; die; }