mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
misc(emailer): Use constants for email types (#1794)
This commit is contained in:
parent
95ccf9bf3e
commit
c95d414ef6
5 changed files with 24 additions and 10 deletions
|
@ -309,6 +309,9 @@ define('HTML_DISABLED', ' disabled ');
|
||||||
define('HTML_READONLY', ' readonly ');
|
define('HTML_READONLY', ' readonly ');
|
||||||
define('HTML_SELECTED', ' selected ');
|
define('HTML_SELECTED', ' selected ');
|
||||||
|
|
||||||
|
define('EMAIL_TYPE_HTML', 'text/html');
|
||||||
|
define('EMAIL_TYPE_TEXT', 'text/plain');
|
||||||
|
|
||||||
// $GPC
|
// $GPC
|
||||||
define('KEY_NAME', 0); // position in $GPC['xxx']
|
define('KEY_NAME', 0); // position in $GPC['xxx']
|
||||||
define('DEF_VAL', 1);
|
define('DEF_VAL', 1);
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
namespace TorrentPier;
|
namespace TorrentPier;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||||
use Symfony\Component\Mailer\Mailer;
|
use Symfony\Component\Mailer\Mailer;
|
||||||
use Symfony\Component\Mailer\Transport\SendmailTransport;
|
use Symfony\Component\Mailer\Transport\SendmailTransport;
|
||||||
|
@ -119,6 +121,7 @@ class Emailer
|
||||||
* @param string $email_format
|
* @param string $email_format
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function send(string $email_format = 'text/plain'): bool
|
public function send(string $email_format = 'text/plain'): bool
|
||||||
{
|
{
|
||||||
|
@ -176,10 +179,15 @@ class Emailer
|
||||||
$message->getHeaders()
|
$message->getHeaders()
|
||||||
->addTextHeader('X-Auto-Response-Suppress', 'OOF, DR, RN, NRN, AutoReply');
|
->addTextHeader('X-Auto-Response-Suppress', 'OOF, DR, RN, NRN, AutoReply');
|
||||||
|
|
||||||
if ($email_format == 'text/html') {
|
switch ($email_format) {
|
||||||
$message->html($this->message);
|
case EMAIL_TYPE_HTML:
|
||||||
} else {
|
$message->html($this->message);
|
||||||
$message->text($this->message);
|
break;
|
||||||
|
case EMAIL_TYPE_TEXT:
|
||||||
|
$message->text($this->message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception('Unknown email format: ' . $email_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send message */
|
/** Send message */
|
||||||
|
|
|
@ -50,6 +50,9 @@ class IndexNow
|
||||||
'naver' => 'searchadvisor.naver.com'
|
'naver' => 'searchadvisor.naver.com'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IndexNow constructor
|
||||||
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
global $bb_cfg;
|
global $bb_cfg;
|
||||||
|
|
|
@ -130,14 +130,14 @@ class Updater
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information of latest TorrentPier version
|
* Returns information of latest TorrentPier version available
|
||||||
*
|
*
|
||||||
* @param bool $allowRC
|
* @param bool $allowPreReleases
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getLastVersion(bool $allowRC = true): array
|
public function getLastVersion(bool $allowPreReleases = true): array
|
||||||
{
|
{
|
||||||
if (!$allowRC) {
|
if (!$allowPreReleases) {
|
||||||
foreach ($this->jsonResponse as $index) {
|
foreach ($this->jsonResponse as $index) {
|
||||||
if (isset($index['prerelease']) && $index['prerelease']) {
|
if (isset($index['prerelease']) && $index['prerelease']) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
<td class="row1 tRight"><b>{L_MASS_EMAIL_MESSAGE_TYPE}</b></td>
|
<td class="row1 tRight"><b>{L_MASS_EMAIL_MESSAGE_TYPE}</b></td>
|
||||||
<td class="row2">
|
<td class="row2">
|
||||||
<select name="message_type">
|
<select name="message_type">
|
||||||
<option value="text/plain" selected>text/plain</option>
|
<option value="{#EMAIL_TYPE_TEXT#}" selected>{#EMAIL_TYPE_TEXT#}</option>
|
||||||
<option value="text/html">text/html</option>
|
<option value="{#EMAIL_TYPE_HTML#}">{#EMAIL_TYPE_HTML#}</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue