<commit_before><?php
namespace Vanderbilt\EmailTriggerExternalModule;

use ExternalModules\AbstractExternalModule;
use ExternalModules\ExternalModules;

require_once __DIR__.'/vendor/autoload.php';

$project_id = $_GET['pid'];
$index =  $_REQUEST['index_modal_record_preview'];
$record =  $_REQUEST['preview_record_id'];

#get data from the DB
$form_name = empty($module->getProjectSetting('form-name'))?array():$module->getProjectSetting('form-name')[$index];
$form_name_event =  empty($module->getProjectSetting('form-name-event'))?array():$module->getProjectSetting('form-name-event')[$index];
$email_from = empty($module->getProjectSetting('email-from'))?array():$module->getProjectSetting('email-from')[$index];
$email_subject =  empty($module->getProjectSetting('email-subject'))?array():$module->getProjectSetting('email-subject')[$index];
$email_text =  empty($module->getProjectSetting('email-text'))?array():$module->getProjectSetting('email-text')[$index];
$datapipe_var = $module->getProjectSetting("datapipe_var", $project_id);

$data = \REDCap::getData($project_id);

if(empty($form_name_event)){
    if(array_key_exists('repeat_instances',$data[$record])){
        foreach ($data[$record]['repeat_instances'] as $event_id=>$value){
            $form_name_event = $event_id;
            break;
        }
    }else{
        foreach ($data[$record] as $event_id=>$value){
            $form_name_event = $event_id;
            break;
        }
    }
}

$mail = new \PHPMailer;

#Email Addresses
$mail = $module->setEmailAddresses($mail, $project_id, $record, $form_name_event, $form_name, 1, $data, $index,\REDCap::isLongitudinal());

$email_to = "";
foreach ($mail->getToAddresses() as $address){
    $email_to .= $address[0].", ";
}

$email_cc = "";
foreach ($mail->getCcAddresses() as $address){
    $email_cc .= $address[0].", ";
}<commit_msg>Bug fix. Updated PHPMailer in Preview Record<commit_after><?php
namespace Vanderbilt\EmailTriggerExternalModule;

use ExternalModules\AbstractExternalModule;
use ExternalModules\ExternalModules;

use PHPMailer\PHPMailer\PHPMailer;

require_once __DIR__.'/vendor/autoload.php';

$project_id = $_GET['pid'];
$index =  $_REQUEST['index_modal_record_preview'];
$record =  $_REQUEST['preview_record_id'];

#get data from the DB
$form_name = empty($module->getProjectSetting('form-name'))?array():$module->getProjectSetting('form-name')[$index];
$form_name_event =  empty($module->getProjectSetting('form-name-event'))?array():$module->getProjectSetting('form-name-event')[$index];
$email_from = empty($module->getProjectSetting('email-from'))?array():$module->getProjectSetting('email-from')[$index];
$email_subject =  empty($module->getProjectSetting('email-subject'))?array():$module->getProjectSetting('email-subject')[$index];
$email_text =  empty($module->getProjectSetting('email-text'))?array():$module->getProjectSetting('email-text')[$index];
$datapipe_var = $module->getProjectSetting("datapipe_var", $project_id);

$data = \REDCap::getData($project_id);

if(empty($form_name_event)){
    if(array_key_exists('repeat_instances',$data[$record])){
        foreach ($data[$record]['repeat_instances'] as $event_id=>$value){
            $form_name_event = $event_id;
            break;
        }
    }else{
        foreach ($data[$record] as $event_id=>$value){
            $form_name_event = $event_id;
            break;
        }
    }
}

$mail = new PHPMailer;

#Email Addresses
$mail = $module->setEmailAddresses($mail, $project_id, $record, $form_name_event, $form_name, 1, $data, $index,\REDCap::isLongitudinal());

$email_to = "";
foreach ($mail->getToAddresses() as $address){
    $email_to .= $address[0].", ";
}

$email_cc = "";
foreach ($mail->getCcAddresses() as $address){
    $email_cc .= $address[0].", ";
}
{'fraction_non_alphanumeric': 0.186409307244844, 'fraction_numerical': 0.0015864621893178213, 'mean_word_length': 6.057835820895522, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2719581', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1233, 'n_words': 168}