To resolve my issue, and after some investigation, I did the following:
In the file modules/Emails/views/MassSaveAjax.php, I modified line 151:
$recordModel->set('toemailinfo', $toMailInfo);
to:
$recordModel->set('toemailinfo', json_encode($toMailInfo));
Then, in the file modules/Emails/models/Record.php, I changed line 62:
// To eliminate the empty value of an array<br />
$toEmailInfo = $this->get('toemailinfo') ? array_filter($this->get('toemailinfo')) : array();
to:
$toEmailInfo = $this->get('toemailinfo') ? array_filter((array)json_decode((string)$this->get('toemailinfo'))) : array();
After these changes, it seems that sending an email from a contact record now works correctly. I haven’t tested beyond this as it was my immediate need.
However, there appears to be something odd: the variable $id is instantiated in multiple places within the send($addToQueue = false) method in modules/Emails/models/Record.php:
line 55
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
line 64
foreach ($toEmailInfo as $id => $emails) {
This solution is a quickfix, and a more in-depth reflection is probably needed to address the root cause.
If you have any suggestions or improvements, I’m happy to hear them.
elge2413elge2413
September 3 0
You can also simply add the following lines in the file modules/Emails/views/MassSaveAjax.php, right after line 162 (inside the massSave method):
//save_module still depends on the $_REQUEST, need to clean it up<br />
$_REQUEST['parent_id'] = $parentIds;<br />
$_REQUEST['id'] = $recordId; // added to Emails_Record_Model::send() / need to clean it up
This works as well, and only requires a single modification!
[This solution is a quickfix, and a more in-depth reflection is probably needed to address the root cause.]
elge2413elge2413
September 3 0
The two previous points must be implemented, and it is also necessary to modify line 64 within the send($addToQueue = false) method in modules/Emails/models/Record.php:
foreach ($toEmailInfo as $id => $emails) {
which should be changed to:
foreach ($toEmailInfo as $_id => $emails) {<br />
This way, there's no ambiguity about the origin of $id!
[This solution is a quickfix, and a more in-depth reflection is probably needed to address the root cause.]