Skip to content

Commit

Permalink
Added option in form email plugin to run content plugins on email text.
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed Aug 27, 2014
1 parent a3cfcee commit 1d1562e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
28 changes: 25 additions & 3 deletions plugins/fabrik_form/email/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,18 @@ public function onAfterProcess()
return;
}

$contentTemplate = $params->get('email_template_content');
$content = $contentTemplate != '' ? $this->_getConentTemplate($contentTemplate) : '';

/**
* Added option to run content plugins on message text. Note that rather than run it one time at the
* end of the following code, after we have assembled all the various options in to a single $message,
* it needs to be run separately on each type of content. This is because we do placeholder replacement
* in various places, which will strip all {text} which doesn't match element names.
*/

$runContentPlugins = $params->get('email_run_content_plugins', '0') === '1';

$contentTemplate = $params->get('email_template_content');
$content = $contentTemplate != '' ? FabrikHelperHTML::getContentTemplate($contentTemplate, both, $runContentPlugins) : '';

// Always send as html as even text email can contain html from wysiwyg editors
$htmlEmail = true;

Expand All @@ -100,13 +109,24 @@ public function onAfterProcess()
return;
}

if ($runContentPlugins === true)
{
FabrikHelperHTML::runContentPlugins($messageTemplate);
}

$messageTemplate = str_replace('{content}', $content, $messageTemplate);
}

$messageText = $params->get('email_message_text', '');

if (!empty($messageText))
{

if ($runContentPlugins === true)
{
FabrikHelperHTML::runContentPlugins($messageText);
}

$messageText = $w->parseMessageForPlaceholder($messageText, $this->data, false);
$messageText = str_replace('{content}', $content, $messageText);
$messageText = str_replace('{template}', $messageTemplate, $messageText);
Expand Down Expand Up @@ -150,6 +170,7 @@ public function onAfterProcess()
$message = str_replace('{fabrik_editurl}', $editURL, $message);
$message = str_replace('{fabrik_viewurl}', $viewURL, $message);


// $$$ rob if email_to is not a valid email address check the raw value to see if that is
$email_to = explode(',', $params->get('email_to'));

Expand Down Expand Up @@ -568,6 +589,7 @@ protected function _getTemplateEmail($emailTemplate)

/**
* Get content item template
* DEPRECATED use FabrikHelperHTML::getContentTemplate() instead
*
* @param int $contentTemplate Joomla article ID to load
*
Expand Down
11 changes: 11 additions & 0 deletions plugins/fabrik_form/email/forms/fields.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@
query="SELECT id AS value, title AS text FROM #__content WHERE state != -2 "
repeat="true" />

<field name="email_run_content_plugins"
type="radio"
class="btn-group"
default="0"
repeat="true"
description="PLG_FABRIK_FORM_EMAIL_RUN_CONTENT_PLUGINS_DESC"
label="PLG_FABRIK_FORM_EMAIL_RUN_CONTENT_PLUGINS_LABEL">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

<field name="email_message_text"
type="fabrikeditor"
description="PLG_FABRIK_FORM_EMAIL_MESSAGE_TEXT_DESC"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ PLG_FABRIK_FORM_EMAIL_ATTACH_EVAL_LABEL="Attachments (eval)"
PLG_FABRIK_FORM_EMAIL_ATTACH_EVAL_DESC="OPTIONAL - PHP code to add attachments. Code just needs to return an array of full path name(s) to desired file(s). Can use placeholders, and/or access form data in $this->data."
PLG_FABRIK_FORM_EMAIL_MESSAGE_TEXT_LABEL="Message Text"
PLG_FABRIK_FORM_EMAIL_MESSAGE_TEXT_DESC="OPTIONAL - text of message. May use placeholders. If specified in addition to an article template, the special placeholder {content} will incude the article template text. If used in addition to the PHP/HTML template, the special placeholder {template} will include that text."

PLG_FABRIK_FORM_EMAIL_RUN_CONTENT_PLUGINS_DESC="Run content plugins on message text. Applies to article, PHP and HTML templates."
PLG_FABRIK_FORM_EMAIL_RUN_CONTENT_PLUGINS_LABEL="Run Plugins"
;Front end
PLG_FORM_EMAIL_DID_NOT_SEND_EMAIL_INVALID_ADDRESS="Could not send email to %s, invalid address"

Expand Down
Empty file modified plugins/fabrik_form/email/tmpl/debug.php
100755 → 100644
Empty file.

0 comments on commit 1d1562e

Please sign in to comment.