Server : LiteSpeed System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : alsaif ( 1057) PHP Version : 7.4.33 Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/alsaif/domains/alsaif.group/public_html/plugins/convertformsapps/email/ |
<?php
/**
* @package Convert Forms
* @version 4.3.3 Pro
*
* @author Tassos Marinos <info@tassos.gr>
* @link https://www.tassos.gr
* @copyright Copyright © 2023 Tassos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use ConvertForms\Tasks\App;
use NRFramework\Email;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use ConvertForms\Tasks\LimitAppUsage;
use ConvertForms\Helper;
class plgConvertFormsAppsEmail extends App
{
/**
* To be able to use this app, the Mail option in the Global Configuration page must be enabled.
*
* @return mixed, null when the requirement is met, array otherwise.
*/
protected function reqMailOption()
{
if (!Factory::getConfig()->get('mailonline'))
{
return [
'text' => $this->lang('SENDING_OFF')
];
}
}
/**
* The trigger that sends the email
*
* @return void
*/
public function actionEmail()
{
// Disable cloaking of email addresses
if (PluginHelper::isEnabled('content', 'emailcloak'))
{
$this->options['body'] .= '{emailcloak=off}';
}
// Trigger Content Plugins
$this->options['body'] = \JHtml::_('content.prepare', $this->options['body']);
// Support if shortcodes. For some reason, if run this after content.prepare, it fails.
Helper::parseIfShortcode($this->options['body'], $this->payload['submission']);
// Since we are using a textarea, we need to convert new line characters to <br> to preserve new lines.
// Consider this is as a temporary workaround until we replace the textarea with a Rich Text editor.
$this->options['body'] = str_replace(["\r\n", "\r", "\n"], '<br>', $this->options['body']);
$mailer = new Email($this->options);
if (!$mailer->send())
{
$this->setError($mailer->error);
}
}
/**
* Get a list with the fields needed to setup the app's event.
*
* @return array
*/
public function getActionEmailSetupFields()
{
return [
[
'name' => Text::_('COM_CONVERTFORMS_APP_SETUP_ACTION'),
'fields' => [
$this->field('subject', ['value' => 'New Submission #{submission.id}']),
$this->field('recipient', ['value' => '{site.email}']),
$this->field('from_name', ['value' => '{site.name}']),
$this->field('from_email', ['value' => '{site.email}']),
$this->field('reply_to', ['required' => false]),
$this->field('reply_to_name', ['required' => false]),
$this->field('cc', ['required' => false]),
$this->field('bcc', ['required' => false]),
$this->field('body', ['type' => 'textarea', 'value' => '{all_fields}']),
$this->field('attachments', ['required' => false])
]
]
];
}
}