Skip to content

Commit

Permalink
Showing the FAQ-text directly in the notification-mail (#2394)
Browse files Browse the repository at this point in the history
* Update Notification.php 

Added support for showing the full question and answer of the faq directly in the email

* Update language_de.php

Added support for showing the faq text directly in the notification-mail.

* Update language_en.php

Added support for showing the faq text directly in the notification-mail.

* PHPCS changes
  • Loading branch information
modelrailroader committed Mar 27, 2023
1 parent c00160b commit 1614645
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion phpmyfaq/lang/language_de.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@

// E-Mailbenachrichtigung
$PMF_LANG['msgMailThanks'] = "Vielen Dank für den Vorschlag";
$PMF_LANG['msgMailCheck'] = "Es ist ein neuer FAQ-Beitrag vorhanden. Sie können diesen im Adminbereich überprüfen.";
$PMF_LANG['msgMailCheck'] = "Es ist ein neuer FAQ-Beitrag vorhanden. Sie können diesen hier oder im Adminbereich überprüfen.";
$PMF_LANG['msgMailContact'] = "Die Anfrage wurde an den Administrator versendet!";

// Fehlermeldungen
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/lang/language_en.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@

// Email notification
$PMF_LANG["msgMailThanks"] = "Thank you for your proposal to the FAQ!";
$PMF_LANG["msgMailCheck"] = "There's a new entry in the FAQ! Please check the admin section.";
$PMF_LANG["msgMailCheck"] = "There's a new entry in the FAQ! Please check it here or in the admin section.";
$PMF_LANG["msgMailContact"] = "Your message has been sent to the administrator.";

// Error messages
Expand Down
15 changes: 13 additions & 2 deletions phpmyfaq/src/phpMyFAQ/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace phpMyFAQ;

use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use phpMyFAQ\Faq;

/**
* Class Notification
Expand All @@ -27,6 +28,8 @@ class Notification
{
private readonly Mail $mail;

private readonly Faq $faq;

/**
* Constructor.
*
Expand All @@ -35,6 +38,7 @@ class Notification
public function __construct(private readonly Configuration $config)
{
$this->mail = new Mail($this->config);
$this->faq = new Faq($this->config);
$this->mail->setReplyTo(
$this->config->getAdminEmail(),
$this->config->getTitle()
Expand Down Expand Up @@ -76,10 +80,17 @@ public function sendNewFaqAdded(array $emails, int $faqId, string $faqLanguage):
$this->mail->addCc($email);
}
$this->mail->subject = $this->config->getTitle() . ': New FAQ was added.';
$this->faq->getRecord($faqId, null, true);
$link = $this->config->getDefaultUrl() . 'admin/?action=editentry&id=' . $faqId . '&lang=' . $faqLanguage;
$this->mail->message = html_entity_decode(
Translation::get('msgMailCheck')
) . "\n\n" . $this->config->getTitle() . ': ' . $this->config->getDefaultUrl(
) . 'admin/?action=editentry&id=' . $faqId . '&lang=' . $faqLanguage;
) . "<p><strong>Frage:</strong> " . $this->faq->getRecordTitle($faqId) . "</p>"
. $this->faq->faqRecord['content']
. "<br />" . $this->config->getTitle()
. ': <a href="' . $link . '">' . $link . "</a>";

$this->mail->setHTMLMessage($this->mail->message);
$this->mail->contentType = 'text/html';

$this->mail->send();
}
Expand Down

0 comments on commit 1614645

Please sign in to comment.