Skip to content

Commit

Permalink
Added parsing of variables in the mail
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuszkrzaczkowski committed Jan 31, 2017
1 parent f8722cf commit bb957a3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
6 changes: 3 additions & 3 deletions plugins/yetiforce/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ window.rcmail && rcmail.addEventListener('init', function (evt) {
frame_name = 'rcmupload' + ts,
frame = rcmail.async_upload_form_frame(frame_name);
data._uploadid = ts;
console.log(data);
jQuery.ajax({
url: "?_task=mail&_action=plugin.yetiforce.addFilesToMail&_id=" + rcmail.env.compose_id,
type: "POST",
Expand Down Expand Up @@ -142,7 +143,7 @@ window.rcmail && rcmail.addEventListener('init', function (evt) {
var oldBody = jQuery('#composebody').val();
jQuery('#composebody').val(html + oldBody);
}
if (typeof data.attachments !== 'undefined') {
if (typeof data.attachments !== 'undefined' && data.attachments !== null) {
rcmail.command('yetiforce.addFilesToMail', data.attachments);
}
}
Expand Down Expand Up @@ -170,14 +171,13 @@ function getMailFromCRM(mailField, moduleName, records) {
},
success: function (data) {
data = JSON.parse(data);
if (data.length == 0 ) {
if (data.length == 0) {
var notifyParams = {
text: window.crm.app.vtranslate('NoFindEmailInRecord'),
animation: 'show'
};
window.crm.Vtiger_Helper_Js.showPnotify(notifyParams);
} else {
console.log(data);
var emails = $('#' + mailField).val();
if (emails != '' && emails.charAt(emails.length - 1) != ',') {
emails = emails + ',';
Expand Down
2 changes: 1 addition & 1 deletion plugins/yetiforce/compose.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions plugins/yetiforce/yetiforce.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ protected function loadCurrentUser()
$ownerObject->retrieveCurrentUserInfoFromFile($_SESSION['crm']['id']);
$this->currentUser = $ownerObject;
vglobal('current_user', $ownerObject);
App\User::setCurrentUserId($_SESSION['crm']['id']);
return true;
}

Expand Down Expand Up @@ -661,15 +662,23 @@ public function getEmailTemplates()
*/
public function getConntentEmailTemplate()
{
$recordId = rcube_utils::get_input_value('id', rcube_utils::INPUT_GPC);
$templeteId = rcube_utils::get_input_value('id', rcube_utils::INPUT_GPC);
$recordId = rcube_utils::get_input_value('record_id', rcube_utils::INPUT_GPC);
$moduleName = rcube_utils::get_input_value('select_module', rcube_utils::INPUT_GPC);
$currentPath = getcwd();
chdir($this->rc->config->get('root_directory'));
$this->loadCurrentUser();
$mail = App\Mail::getTemplete($recordId);
$emailTemplates ['subject'] = $mail['subject'];
$emailTemplates ['content'] = $mail['content'];
$emailTemplates ['attachments'] = $mail['attachments'];
echo App\Json::encode($emailTemplates);
$mail = App\Mail::getTemplete($templeteId);
if ($recordId) {
$textParser = \App\TextParser::getInstanceById($recordId, $moduleName);
$mail['subject'] = $textParser->setContent($mail['subject'])->parse()->getContent();
$mail['content'] = $textParser->setContent($mail['content'])->parse()->getContent();
}
echo App\Json::encode([
'subject' => $mail['subject'],
'content' => $mail['content'],
'attachments' => $mail['attachments'],
]);
chdir($currentPath);
exit;
}
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
return [
'patch' => '2017.01.23',
'version' => '0.0.23'
'patch' => '2017.01.31',
'version' => '0.0.24'
];

0 comments on commit bb957a3

Please sign in to comment.