Skip to content
Snippets Groups Projects
Commit bf043713 authored by Peter Rotich's avatar Peter Rotich
Browse files

Collaborators Fixes

* Dont't fetch templates while in a loop
* Tidy up the code
parent 11dad9b5
Branches
Tags
No related merge requests found
...@@ -2939,47 +2939,41 @@ implements RestrictedAccess, Threadable, Searchable { ...@@ -2939,47 +2939,41 @@ implements RestrictedAccess, Threadable, Searchable {
$user = $this->getOwner(); $user = $this->getOwner();
if (($email=$email) if (($email=$email)
&& ($tpl = $dept->getTemplate()) && ($tpl = $dept->getTemplate())
&& ($msg=$tpl->getReplyMsgTemplate()) && ($msg=$tpl->getReplyMsgTemplate())) {
) {
$msg = $this->replaceVars($msg->asArray(), $msg = $this->replaceVars($msg->asArray(),
$variables + array('recipient' => $user) $variables + array('recipient' => $user)
); );
$attachments = $cfg->emailAttachments()?$response->getAttachments():array();
}
if ($vars['emailcollab'] == 1) { $attachments = $cfg->emailAttachments() ? $response->getAttachments() : array();
//Cc collaborators //Cc collaborators
if($vars['ccs']) { $collabsCc = array();
$collabsCc = array(); if ($vars['ccs'] && $vars['emailcollab']) {
$collabsCc[] = Collaborator::getCollabList($vars['ccs']); $collabsCc[] = Collaborator::getCollabList($vars['ccs']);
$collabsCc['cc'] = $collabsCc; $collabsCc['cc'] = $collabsCc;
$email->send($user, $msg['subj'], $msg['body'], $attachments,
$options, $collabsCc);
}
else {
$email->send($user, $msg['subj'], $msg['body'], $attachments,
$options);
} }
$email->send($user, $msg['subj'], $msg['body'], $attachments,
$options, $collabsCc);
//Bcc Collaborators //Bcc Collaborators
if($vars['bccs']) { if ($vars['bccs']
foreach ($vars['bccs'] as $uid) { && $vars['emailcollab']
$recipient = User::lookup($uid); && ($bcctpl = $dept->getTemplate())
if (($bcctpl = $dept->getTemplate())
&& ($bccmsg=$bcctpl->getReplyMsgTemplate())) { && ($bccmsg=$bcctpl->getReplyMsgTemplate())) {
$bccmsg = $this->replaceVars($bccmsg->asArray(), $variables + foreach ($vars['bccs'] as $uid) {
array('recipient' => $user, 'recipient.name.first' => $recipient->getName()->getFirst()) if (!($recipient = User::lookup($uid)))
); continue;
$email->send($recipient, $bccmsg['subj'], $bccmsg['body'], $attachments, $msg = $this->replaceVars($bccmsg->asArray(), $variables + array(
$options); 'recipient' => $user,
'recipient.name.first' =>
$recipient->getName()->getFirst()));
$email->send($recipient, $msg['subj'], $msg['body'], $attachments, $options);
} }
}
} }
} }
else
$email->send($user, $msg['subj'], $msg['body'], $attachments,
$options);
return $response; return $response;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment