protected function sendClarificationEmail(Request $r, $time) { if (!OMEGAUP_EMAIL_SEND_EMAILS || !is_null($r['clarification']->answer) || !$r['problem']->email_clarifications) { return; } try { $emails = ProblemsDAO::getExplicitAdminEmails($r['problem']); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = OMEGAUP_EMAIL_SMTP_HOST; $mail->SMTPAuth = true; $mail->Password = OMEGAUP_EMAIL_SMTP_PASSWORD; $mail->From = OMEGAUP_EMAIL_SMTP_FROM; $mail->Port = 465; $mail->SMTPSecure = 'ssl'; $mail->Username = OMEGAUP_EMAIL_SMTP_FROM; $mail->FromName = OMEGAUP_EMAIL_SMTP_FROM; foreach ($emails as $email) { $mail->AddAddress($email); } $mail->isHTML(true); global $smarty; $email_params = array('clarification_id' => $r['clarification']->clarification_id, 'clarification_body' => htmlspecialchars($r['clarification']->message), 'problem_alias' => $r['problem']->alias, 'problem_name' => htmlspecialchars($r['problem']->title), 'url' => is_null($r['contest']) ? 'https://omegaup.com/arena/problem/' . $r['problem']->alias . '#clarifications' : 'https://omegaup.com/arena/' . $r['contest']->alias . '#clarifications', 'user_name' => $r['user']->username); $mail->Subject = ApiUtils::FormatString($smarty->getConfigVars('clarificationEmailSubject'), $email_params); $mail->Body = ApiUtils::FormatString($smarty->getConfigVars('clarificationEmailBody'), $email_params); if (!$mail->Send()) { $this->log->error('Failed to send mail: ' . $mail->ErrorInfo); } } catch (Exception $e) { $this->log->error('Failed to send clarification email ' . $e->getMessage()); } }
protected function getErrorMessage() { // Obtener el texto final (ya localizado) de smarty. global $smarty; $localizedText = $smarty->getConfigVars($this->message); if (empty($localizedText)) { self::$log->error("Untranslated error message: {$this->message}"); return "{untranslated:{$this->message}}"; } $localizedText = ApiUtils::FormatString($localizedText, $this->additional_parameters); if ($this->parameter == null) { return $localizedText; } else { return "{$localizedText}: {$this->parameter}"; } }