Fix phpcs
More secured sendEmailsReminder()
This commit is contained in:
parent
9868140693
commit
ed743c9dbb
@ -1965,6 +1965,8 @@ class ActionComm extends CommonObject
|
||||
$error = 0;
|
||||
$this->output = '';
|
||||
$this->error = '';
|
||||
$nbMailSend = 0;
|
||||
$errorsMsg = array();
|
||||
|
||||
if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible.
|
||||
{
|
||||
@ -2005,68 +2007,68 @@ class ActionComm extends CommonObject
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
//Select email template
|
||||
$arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1);
|
||||
//Select email template
|
||||
$arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1);
|
||||
|
||||
// Load event
|
||||
$res = $this->fetch($actionCommReminder->fk_actioncomm);
|
||||
if ($res > 0)
|
||||
{
|
||||
// PREPARE EMAIL
|
||||
// Load event
|
||||
$res = $this->fetch($actionCommReminder->fk_actioncomm);
|
||||
if ($res > 0)
|
||||
{
|
||||
// PREPARE EMAIL
|
||||
|
||||
// Make substitution in email content
|
||||
$substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this);
|
||||
// Make substitution in email content
|
||||
$substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this);
|
||||
|
||||
complete_substitutions_array($substitutionarray, $langs, $this);
|
||||
complete_substitutions_array($substitutionarray, $langs, $this);
|
||||
|
||||
// Content
|
||||
$sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
|
||||
// Content
|
||||
$sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
|
||||
|
||||
//Topic
|
||||
$sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder'));
|
||||
//Topic
|
||||
$sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder'));
|
||||
|
||||
// Recipient
|
||||
$recipient = new User($this->db);
|
||||
$res = $recipient->fetch($actionCommReminder->fk_user);
|
||||
if ($res > 0 && !empty($recipient->email)) $to = $recipient->email;
|
||||
else {
|
||||
$errorsMsg[] = "Failed to load recipient";
|
||||
$error++;
|
||||
}
|
||||
// Recipient
|
||||
$recipient = new User($this->db);
|
||||
$res = $recipient->fetch($actionCommReminder->fk_user);
|
||||
if ($res > 0 && !empty($recipient->email)) $to = $recipient->email;
|
||||
else {
|
||||
$errorsMsg[] = "Failed to load recipient";
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Sender
|
||||
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
|
||||
if (empty($from)) {
|
||||
$errorsMsg[] = "Failed to load recipient";
|
||||
$error++;
|
||||
}
|
||||
// Sender
|
||||
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
|
||||
if (empty($from)) {
|
||||
$errorsMsg[] = "Failed to load recipient";
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Errors Recipient
|
||||
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
|
||||
// Errors Recipient
|
||||
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
|
||||
|
||||
// Mail Creation
|
||||
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', '');
|
||||
// Mail Creation
|
||||
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', '');
|
||||
|
||||
// Sending Mail
|
||||
if ($cMailFile->sendfile())
|
||||
{
|
||||
$actionCommReminder->status = $actionCommReminder::STATUS_DONE;
|
||||
$res = $actionCommReminder->update($user);
|
||||
if ($res < 0)
|
||||
{
|
||||
$errorsMsg[] = "Failed to update status of ActionComm Reminder";
|
||||
$error++;
|
||||
}
|
||||
else $nbMailSend++;
|
||||
}
|
||||
else {
|
||||
$errorsMsg[] = $cMailFile->error.' : '.$to;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$error++;
|
||||
}
|
||||
// Sending Mail
|
||||
if ($cMailFile->sendfile())
|
||||
{
|
||||
$actionCommReminder->status = $actionCommReminder::STATUS_DONE;
|
||||
$res = $actionCommReminder->update($user);
|
||||
if ($res < 0)
|
||||
{
|
||||
$errorsMsg[] = "Failed to update status of ActionComm Reminder";
|
||||
//$error++; Do not add error here.
|
||||
break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first.
|
||||
} else {
|
||||
$nbMailSend++;
|
||||
}
|
||||
} else {
|
||||
$errorsMsg[] = $cMailFile->error.' : '.$to;
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -2087,12 +2089,14 @@ class ActionComm extends CommonObject
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->output = 'Nb of emails sent : '.$nbMailSend;
|
||||
$this->db->commit();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
$this->db->rollback();
|
||||
return (!empty($errorsMsg)) ? end($errorsMsg) : $error;
|
||||
$this->error = (!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error;
|
||||
return $error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7977,6 +7977,7 @@ class Form
|
||||
*
|
||||
* @param string $prefix Prefix
|
||||
* @param string $modelType Model type
|
||||
* @param int $default 1=Show also Default mail template
|
||||
* @return string HTML select string
|
||||
*/
|
||||
public function selectModelMail($prefix, $modelType = '', $default = 0)
|
||||
|
||||
@ -215,7 +215,7 @@ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentL
|
||||
|
||||
if (!empty(${$statusVarNamePrefix.'badgeStatus'.$statusName})) {
|
||||
print "\n/* ".strtoupper($commentLabel)." */\n";
|
||||
|
||||
|
||||
$thisBadgeBackgroundColor = $thisBadgeBorderColor = ${$statusVarNamePrefix.'badgeStatus'.$statusName};
|
||||
|
||||
|
||||
@ -233,7 +233,7 @@ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentL
|
||||
|
||||
if (in_array((string) $statusName, array('0', '5', '9'))) $thisBadgeTextColor = '#999999';
|
||||
if (in_array((string) $statusName, array('6'))) $thisBadgeTextColor = '#777777';
|
||||
|
||||
|
||||
print $cssPrefix.".badge-status".$statusName." {\n";
|
||||
print " color: ".$thisBadgeTextColor." !important;\n";
|
||||
if (in_array((string) $statusName, $TBadgeBorderOnly)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user