mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge pull request #6483 from rxu/ticket/17135
[ticket/17135] Introduce Symfony Mailer for emails backend
This commit is contained in:
commit
485d72f0e8
72 changed files with 3080 additions and 2823 deletions
|
@ -33,7 +33,6 @@ require_once $phpbb_root_path . 'includes/functions_compress.' . $phpEx;
|
||||||
require_once $phpbb_root_path . 'includes/functions_content.' . $phpEx;
|
require_once $phpbb_root_path . 'includes/functions_content.' . $phpEx;
|
||||||
require_once $phpbb_root_path . 'includes/functions_display.' . $phpEx;
|
require_once $phpbb_root_path . 'includes/functions_display.' . $phpEx;
|
||||||
require_once $phpbb_root_path . 'includes/functions_mcp.' . $phpEx;
|
require_once $phpbb_root_path . 'includes/functions_mcp.' . $phpEx;
|
||||||
require_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
|
|
||||||
require_once $phpbb_root_path . 'includes/functions_module.' . $phpEx;
|
require_once $phpbb_root_path . 'includes/functions_module.' . $phpEx;
|
||||||
require_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
|
require_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
|
||||||
require_once $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx;
|
require_once $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx;
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
"symfony/http-foundation": "^6.3",
|
"symfony/http-foundation": "^6.3",
|
||||||
"symfony/http-kernel": "^6.3",
|
"symfony/http-kernel": "^6.3",
|
||||||
"symfony/polyfill-mbstring": "^1.23",
|
"symfony/polyfill-mbstring": "^1.23",
|
||||||
|
"symfony/mailer": "^6.3",
|
||||||
"symfony/mime": "^6.3",
|
"symfony/mime": "^6.3",
|
||||||
"symfony/process": "^6.3",
|
"symfony/process": "^6.3",
|
||||||
"symfony/proxy-manager-bridge": "^6.3",
|
"symfony/proxy-manager-bridge": "^6.3",
|
||||||
|
|
226
phpBB/composer.lock
generated
226
phpBB/composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "f6e182dafa1a6e6a60136e35d5379532",
|
"content-hash": "2ce7bc4e8f61d065ff471afa38f12394",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bantu/ini-get-wrapper",
|
"name": "bantu/ini-get-wrapper",
|
||||||
|
@ -1417,6 +1417,150 @@
|
||||||
],
|
],
|
||||||
"time": "2022-10-12T20:51:15+00:00"
|
"time": "2022-10-12T20:51:15+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "doctrine/lexer",
|
||||||
|
"version": "3.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/doctrine/lexer.git",
|
||||||
|
"reference": "84a527db05647743d50373e0ec53a152f2cde568"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/doctrine/lexer/zipball/84a527db05647743d50373e0ec53a152f2cde568",
|
||||||
|
"reference": "84a527db05647743d50373e0ec53a152f2cde568",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^8.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/coding-standard": "^10",
|
||||||
|
"phpstan/phpstan": "^1.9",
|
||||||
|
"phpunit/phpunit": "^9.5",
|
||||||
|
"psalm/plugin-phpunit": "^0.18.3",
|
||||||
|
"vimeo/psalm": "^5.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Doctrine\\Common\\Lexer\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Guilherme Blanco",
|
||||||
|
"email": "guilhermeblanco@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Roman Borschel",
|
||||||
|
"email": "roman@code-factory.org"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Johannes Schmitt",
|
||||||
|
"email": "schmittjoh@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.",
|
||||||
|
"homepage": "https://www.doctrine-project.org/projects/lexer.html",
|
||||||
|
"keywords": [
|
||||||
|
"annotations",
|
||||||
|
"docblock",
|
||||||
|
"lexer",
|
||||||
|
"parser",
|
||||||
|
"php"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/doctrine/lexer/issues",
|
||||||
|
"source": "https://github.com/doctrine/lexer/tree/3.0.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.doctrine-project.org/sponsorship.html",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://www.patreon.com/phpdoctrine",
|
||||||
|
"type": "patreon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-12-15T16:57:16+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "egulias/email-validator",
|
||||||
|
"version": "4.0.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/egulias/EmailValidator.git",
|
||||||
|
"reference": "ebaaf5be6c0286928352e054f2d5125608e5405e"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/ebaaf5be6c0286928352e054f2d5125608e5405e",
|
||||||
|
"reference": "ebaaf5be6c0286928352e054f2d5125608e5405e",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"doctrine/lexer": "^2.0 || ^3.0",
|
||||||
|
"php": ">=8.1",
|
||||||
|
"symfony/polyfill-intl-idn": "^1.26"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^10.2",
|
||||||
|
"vimeo/psalm": "^5.12"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "4.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Egulias\\EmailValidator\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Eduardo Gulias Davis"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A library for validating emails against several RFCs",
|
||||||
|
"homepage": "https://github.com/egulias/EmailValidator",
|
||||||
|
"keywords": [
|
||||||
|
"email",
|
||||||
|
"emailvalidation",
|
||||||
|
"emailvalidator",
|
||||||
|
"validation",
|
||||||
|
"validator"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/egulias/EmailValidator/issues",
|
||||||
|
"source": "https://github.com/egulias/EmailValidator/tree/4.0.2"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/egulias",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-10-06T06:47:41+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "friendsofphp/proxy-manager-lts",
|
"name": "friendsofphp/proxy-manager-lts",
|
||||||
"version": "v1.0.18",
|
"version": "v1.0.18",
|
||||||
|
@ -4342,6 +4486,86 @@
|
||||||
],
|
],
|
||||||
"time": "2024-11-27T12:49:36+00:00"
|
"time": "2024-11-27T12:49:36+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/mailer",
|
||||||
|
"version": "v6.4.13",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/mailer.git",
|
||||||
|
"reference": "c2f7e0d8d7ac8fe25faccf5d8cac462805db2663"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/mailer/zipball/c2f7e0d8d7ac8fe25faccf5d8cac462805db2663",
|
||||||
|
"reference": "c2f7e0d8d7ac8fe25faccf5d8cac462805db2663",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"egulias/email-validator": "^2.1.10|^3|^4",
|
||||||
|
"php": ">=8.1",
|
||||||
|
"psr/event-dispatcher": "^1",
|
||||||
|
"psr/log": "^1|^2|^3",
|
||||||
|
"symfony/event-dispatcher": "^5.4|^6.0|^7.0",
|
||||||
|
"symfony/mime": "^6.2|^7.0",
|
||||||
|
"symfony/service-contracts": "^2.5|^3"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"symfony/http-client-contracts": "<2.5",
|
||||||
|
"symfony/http-kernel": "<5.4",
|
||||||
|
"symfony/messenger": "<6.2",
|
||||||
|
"symfony/mime": "<6.2",
|
||||||
|
"symfony/twig-bridge": "<6.2.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"symfony/console": "^5.4|^6.0|^7.0",
|
||||||
|
"symfony/http-client": "^5.4|^6.0|^7.0",
|
||||||
|
"symfony/messenger": "^6.2|^7.0",
|
||||||
|
"symfony/twig-bridge": "^6.2|^7.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Component\\Mailer\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Helps sending emails",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/mailer/tree/v6.4.13"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-09-25T14:18:03+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/mime",
|
"name": "symfony/mime",
|
||||||
"version": "v6.4.13",
|
"version": "v6.4.13",
|
||||||
|
|
|
@ -19,6 +19,7 @@ imports:
|
||||||
- { resource: services_http.yml }
|
- { resource: services_http.yml }
|
||||||
- { resource: services_language.yml }
|
- { resource: services_language.yml }
|
||||||
- { resource: services_mention.yml }
|
- { resource: services_mention.yml }
|
||||||
|
- { resource: services_messenger.yml }
|
||||||
- { resource: services_migrator.yml }
|
- { resource: services_migrator.yml }
|
||||||
- { resource: services_mimetype_guesser.yml }
|
- { resource: services_mimetype_guesser.yml }
|
||||||
- { resource: services_module.yml }
|
- { resource: services_module.yml }
|
||||||
|
|
|
@ -327,6 +327,7 @@ services:
|
||||||
- '@config'
|
- '@config'
|
||||||
- '@language'
|
- '@language'
|
||||||
- '@log'
|
- '@log'
|
||||||
|
- '@messenger.method.email'
|
||||||
- '@notification_manager'
|
- '@notification_manager'
|
||||||
- '@user_loader'
|
- '@user_loader'
|
||||||
- '%core.root_path%'
|
- '%core.root_path%'
|
||||||
|
@ -341,6 +342,7 @@ services:
|
||||||
- '@dbal.conn'
|
- '@dbal.conn'
|
||||||
- '@config'
|
- '@config'
|
||||||
- '@language'
|
- '@language'
|
||||||
|
- '@messenger.method.email'
|
||||||
- '@passwords.manager'
|
- '@passwords.manager'
|
||||||
- '%core.root_path%'
|
- '%core.root_path%'
|
||||||
- '%core.php_ext%'
|
- '%core.php_ext%'
|
||||||
|
|
|
@ -86,10 +86,9 @@ services:
|
||||||
cron.task.core.queue:
|
cron.task.core.queue:
|
||||||
class: phpbb\cron\task\core\queue
|
class: phpbb\cron\task\core\queue
|
||||||
arguments:
|
arguments:
|
||||||
- '%core.root_path%'
|
|
||||||
- '%core.php_ext%'
|
|
||||||
- '@config'
|
- '@config'
|
||||||
- '%core.cache_dir%'
|
- '@messenger.queue'
|
||||||
|
- '%core.messenger_queue_file%'
|
||||||
calls:
|
calls:
|
||||||
- [set_name, [cron.task.core.queue]]
|
- [set_name, [cron.task.core.queue]]
|
||||||
tags:
|
tags:
|
||||||
|
|
57
phpBB/config/default/container/services_messenger.yml
Normal file
57
phpBB/config/default/container/services_messenger.yml
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
parameters:
|
||||||
|
core.messenger_queue_file: '%core.cache_dir%queue.%core.php_ext%'
|
||||||
|
|
||||||
|
services:
|
||||||
|
messenger.method_collection:
|
||||||
|
class: phpbb\di\service_collection
|
||||||
|
arguments:
|
||||||
|
- '@service_container'
|
||||||
|
tags:
|
||||||
|
- { name: service_collection, tag: messenger.method, class_name_aware: true }
|
||||||
|
|
||||||
|
messenger.method.base:
|
||||||
|
class: phpbb\messenger\method\base
|
||||||
|
shared: false
|
||||||
|
arguments:
|
||||||
|
- '@assets.bag'
|
||||||
|
- '@config'
|
||||||
|
- '@dispatcher'
|
||||||
|
- '@language'
|
||||||
|
- '@messenger.queue'
|
||||||
|
- '@path_helper'
|
||||||
|
- '@request'
|
||||||
|
- '@template.twig.extensions.collection'
|
||||||
|
- '@template.twig.lexer'
|
||||||
|
- '@user'
|
||||||
|
- '%core.root_path%'
|
||||||
|
- '%core.template.cache_path%'
|
||||||
|
- '@?ext.manager'
|
||||||
|
- '@?log'
|
||||||
|
|
||||||
|
messenger.method.email:
|
||||||
|
class: phpbb\messenger\method\email
|
||||||
|
shared: false
|
||||||
|
parent: messenger.method.base
|
||||||
|
calls:
|
||||||
|
- [init, []]
|
||||||
|
- [set_transport, []]
|
||||||
|
tags:
|
||||||
|
- { name: messenger.method }
|
||||||
|
|
||||||
|
messenger.method.jabber:
|
||||||
|
class: phpbb\messenger\method\jabber
|
||||||
|
shared: false
|
||||||
|
parent: messenger.method.base
|
||||||
|
calls:
|
||||||
|
- [init, []]
|
||||||
|
tags:
|
||||||
|
- { name: messenger.method }
|
||||||
|
|
||||||
|
messenger.queue:
|
||||||
|
class: phpbb\messenger\queue
|
||||||
|
shared: false
|
||||||
|
arguments:
|
||||||
|
- '@config'
|
||||||
|
- '@dispatcher'
|
||||||
|
- '@messenger.method_collection'
|
||||||
|
- '%core.messenger_queue_file%'
|
|
@ -229,6 +229,7 @@ services:
|
||||||
- '%core.root_path%'
|
- '%core.root_path%'
|
||||||
- '%core.php_ext%'
|
- '%core.php_ext%'
|
||||||
- '%tables.notification_emails%'
|
- '%tables.notification_emails%'
|
||||||
|
- '@messenger.method_collection'
|
||||||
tags:
|
tags:
|
||||||
- { name: notification.method }
|
- { name: notification.method }
|
||||||
|
|
||||||
|
@ -241,6 +242,7 @@ services:
|
||||||
- '@config'
|
- '@config'
|
||||||
- '%core.root_path%'
|
- '%core.root_path%'
|
||||||
- '%core.php_ext%'
|
- '%core.php_ext%'
|
||||||
|
- '@messenger.method_collection'
|
||||||
tags:
|
tags:
|
||||||
- { name: notification.method }
|
- { name: notification.method }
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ services:
|
||||||
- '@controller.helper'
|
- '@controller.helper'
|
||||||
- '@language'
|
- '@language'
|
||||||
- '@log'
|
- '@log'
|
||||||
|
- '@messenger.method.email'
|
||||||
- '@passwords.manager'
|
- '@passwords.manager'
|
||||||
- '@request'
|
- '@request'
|
||||||
- '@template'
|
- '@template'
|
||||||
|
|
|
@ -5,6 +5,7 @@ imports:
|
||||||
- { resource: ../../default/container/services_filesystem.yml }
|
- { resource: ../../default/container/services_filesystem.yml }
|
||||||
- { resource: ../../default/container/services_http.yml }
|
- { resource: ../../default/container/services_http.yml }
|
||||||
- { resource: ../../default/container/services_language.yml }
|
- { resource: ../../default/container/services_language.yml }
|
||||||
|
- { resource: ../../default/container/services_messenger.yml }
|
||||||
- { resource: ../../default/container/services_php.yml }
|
- { resource: ../../default/container/services_php.yml }
|
||||||
- { resource: ../../default/container/services_routing.yml }
|
- { resource: ../../default/container/services_routing.yml }
|
||||||
- { resource: ../../default/container/services_twig.yml }
|
- { resource: ../../default/container/services_twig.yml }
|
||||||
|
|
|
@ -24,7 +24,6 @@ services:
|
||||||
- '@installer.helper.config'
|
- '@installer.helper.config'
|
||||||
- '@installer.helper.iohandler'
|
- '@installer.helper.iohandler'
|
||||||
- '%core.root_path%'
|
- '%core.root_path%'
|
||||||
- '%core.php_ext%'
|
|
||||||
tags:
|
tags:
|
||||||
- { name: install_finish, order: 3 }
|
- { name: install_finish, order: 3 }
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ installer:
|
||||||
smtp_delivery : ~
|
smtp_delivery : ~
|
||||||
smtp_host: ~
|
smtp_host: ~
|
||||||
smtp_port: ~
|
smtp_port: ~
|
||||||
smtp_auth: ~
|
|
||||||
smtp_user: ~
|
smtp_user: ~
|
||||||
smtp_pass: ~
|
smtp_pass: ~
|
||||||
|
|
||||||
|
|
|
@ -473,7 +473,6 @@ class acp_board
|
||||||
'smtp_delivery' => array('lang' => 'USE_SMTP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
|
'smtp_delivery' => array('lang' => 'USE_SMTP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
'smtp_host' => array('lang' => 'SMTP_SERVER', 'validate' => 'string', 'type' => 'text:25:50', 'explain' => true),
|
'smtp_host' => array('lang' => 'SMTP_SERVER', 'validate' => 'string', 'type' => 'text:25:50', 'explain' => true),
|
||||||
'smtp_port' => array('lang' => 'SMTP_PORT', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true),
|
'smtp_port' => array('lang' => 'SMTP_PORT', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true),
|
||||||
'smtp_auth_method' => array('lang' => 'SMTP_AUTH_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true),
|
|
||||||
'smtp_username' => array('lang' => 'SMTP_USERNAME', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true),
|
'smtp_username' => array('lang' => 'SMTP_USERNAME', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true),
|
||||||
'smtp_password' => array('lang' => 'SMTP_PASSWORD', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true),
|
'smtp_password' => array('lang' => 'SMTP_PASSWORD', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true),
|
||||||
'smtp_verify_peer' => array('lang' => 'SMTP_VERIFY_PEER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
|
'smtp_verify_peer' => array('lang' => 'SMTP_VERIFY_PEER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
|
@ -721,17 +720,16 @@ class acp_board
|
||||||
{
|
{
|
||||||
if ($config['email_enable'])
|
if ($config['email_enable'])
|
||||||
{
|
{
|
||||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
$email_method = $phpbb_container->get('messenger.method.email');
|
||||||
|
$email_method->set_use_queue(false);
|
||||||
$messenger = new messenger(false);
|
$email_method->template('test');
|
||||||
$messenger->template('test');
|
$email_method->set_addresses($user->data);
|
||||||
$messenger->set_addresses($user->data);
|
$email_method->anti_abuse_headers($config, $user);
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
$email_method->assign_vars([
|
||||||
$messenger->assign_vars(array(
|
|
||||||
'USERNAME' => html_entity_decode($user->data['username'], ENT_COMPAT),
|
'USERNAME' => html_entity_decode($user->data['username'], ENT_COMPAT),
|
||||||
'MESSAGE' => html_entity_decode($request->variable('send_test_email_text', '', true), ENT_COMPAT),
|
'MESSAGE' => html_entity_decode($request->variable('send_test_email_text', '', true), ENT_COMPAT),
|
||||||
));
|
]);
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
$email_method->send();
|
||||||
|
|
||||||
trigger_error($user->lang('TEST_EMAIL_SENT') . adm_back_link($this->u_action));
|
trigger_error($user->lang('TEST_EMAIL_SENT') . adm_back_link($this->u_action));
|
||||||
}
|
}
|
||||||
|
@ -884,30 +882,6 @@ class acp_board
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Select mail authentication method
|
|
||||||
*/
|
|
||||||
function mail_auth_select($selected_method, $key = '')
|
|
||||||
{
|
|
||||||
global $user;
|
|
||||||
|
|
||||||
$auth_methods = ['PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP'];
|
|
||||||
$s_smtp_auth_options = [];
|
|
||||||
|
|
||||||
foreach ($auth_methods as $method)
|
|
||||||
{
|
|
||||||
$s_smtp_auth_options[] = [
|
|
||||||
'value' => $method,
|
|
||||||
'selected' => $selected_method == $method,
|
|
||||||
'label' => $user->lang('SMTP_' . str_replace('-', '_', $method)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'options' => $s_smtp_auth_options,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select full folder action
|
* Select full folder action
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
|
@ -156,9 +158,9 @@ class acp_email
|
||||||
|
|
||||||
foreach ($rows as $row)
|
foreach ($rows as $row)
|
||||||
{
|
{
|
||||||
if (($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email']) ||
|
if (($row['user_notify_type'] == messenger_interface::NOTIFY_EMAIL && $row['user_email']) ||
|
||||||
($row['user_notify_type'] == NOTIFY_IM && $row['user_jabber']) ||
|
($row['user_notify_type'] == messenger_interface::NOTIFY_IM && $row['user_jabber']) ||
|
||||||
($row['user_notify_type'] == NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber'])))
|
($row['user_notify_type'] == messenger_interface::NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber'])))
|
||||||
{
|
{
|
||||||
if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type)
|
if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type)
|
||||||
{
|
{
|
||||||
|
@ -182,25 +184,13 @@ class acp_email
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the messages
|
|
||||||
if (!class_exists('messenger'))
|
|
||||||
{
|
|
||||||
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('get_group_name'))
|
|
||||||
{
|
|
||||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
||||||
}
|
|
||||||
$messenger = new messenger($use_queue);
|
|
||||||
|
|
||||||
$errored = false;
|
$errored = false;
|
||||||
|
|
||||||
$email_template = 'admin_send_email';
|
$email_template = 'admin_send_email';
|
||||||
$template_data = array(
|
$template_data = [
|
||||||
'CONTACT_EMAIL' => phpbb_get_board_contact($config, $phpEx),
|
'CONTACT_EMAIL' => phpbb_get_board_contact($config, $phpEx),
|
||||||
'MESSAGE' => html_entity_decode($message, ENT_COMPAT),
|
'MESSAGE' => html_entity_decode($message, ENT_COMPAT),
|
||||||
);
|
];
|
||||||
$generate_log_entry = true;
|
$generate_log_entry = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -229,36 +219,64 @@ class acp_email
|
||||||
);
|
);
|
||||||
extract($phpbb_dispatcher->trigger_event('core.acp_email_send_before', compact($vars)));
|
extract($phpbb_dispatcher->trigger_event('core.acp_email_send_before', compact($vars)));
|
||||||
|
|
||||||
|
/** @var \phpbb\di\service_collection */
|
||||||
|
$messenger = $phpbb_container->get('messenger.method_collection');
|
||||||
|
$messenger_collection_iterator = $messenger->getIterator();
|
||||||
for ($i = 0, $size = count($email_list); $i < $size; $i++)
|
for ($i = 0, $size = count($email_list); $i < $size; $i++)
|
||||||
{
|
{
|
||||||
$used_lang = $email_list[$i][0]['lang'];
|
$used_lang = $email_list[$i][0]['lang'];
|
||||||
$used_method = $email_list[$i][0]['method'];
|
$used_method = $email_list[$i][0]['method'];
|
||||||
|
|
||||||
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
|
{
|
||||||
|
$notify_method = $messenger_method->get_id();
|
||||||
|
if ($notify_method == $used_method || $used_method == messenger_interface::NOTIFY_BOTH)
|
||||||
|
{
|
||||||
|
$messenger_method->set_use_queue($use_queue);
|
||||||
|
$messenger_method->template($email_template, $used_lang);
|
||||||
|
$messenger_method->subject(html_entity_decode($subject, ENT_COMPAT));
|
||||||
|
$messenger_method->assign_vars($template_data);
|
||||||
|
|
||||||
|
if ($notify_method == messenger_interface::NOTIFY_EMAIL)
|
||||||
|
{
|
||||||
for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++)
|
for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++)
|
||||||
{
|
{
|
||||||
$email_row = $email_list[$i][$j];
|
$email_row = $email_list[$i][$j];
|
||||||
|
if (count($email_list[$i]) == 1)
|
||||||
$messenger->{((count($email_list[$i]) == 1) ? 'to' : 'bcc')}($email_row['email'], $email_row['name']);
|
{
|
||||||
$messenger->im($email_row['jabber'], $email_row['name']);
|
$messenger_method->to($email_row['email'], $email_row['name']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$messenger_method->bcc($email_row['email'], $email_row['name']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$messenger->template($email_template, $used_lang);
|
$messenger_method->anti_abuse_headers($config, $user);
|
||||||
|
$messenger_method->set_mail_priority($priority);
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
}
|
||||||
|
else if ($notify_method == messenger_interface::NOTIFY_IM)
|
||||||
$messenger->subject(html_entity_decode($subject, ENT_COMPAT));
|
|
||||||
$messenger->set_mail_priority($priority);
|
|
||||||
|
|
||||||
$messenger->assign_vars($template_data);
|
|
||||||
|
|
||||||
if (!($messenger->send($used_method)))
|
|
||||||
{
|
{
|
||||||
$errored = true;
|
for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++)
|
||||||
|
{
|
||||||
|
$email_row = $email_list[$i][$j];
|
||||||
|
$messenger_method->to($email_row['jabber'], $email_row['name']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$errored = !$messenger_method->send() || $errored;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($email_list);
|
unset($email_list);
|
||||||
|
|
||||||
$messenger->save_queue();
|
if ($use_queue)
|
||||||
|
{
|
||||||
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
|
{
|
||||||
|
$messenger_method->save_queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($generate_log_entry)
|
if ($generate_log_entry)
|
||||||
{
|
{
|
||||||
|
|
|
@ -114,29 +114,19 @@ class acp_inactive
|
||||||
|
|
||||||
if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !empty($inactive_users))
|
if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !empty($inactive_users))
|
||||||
{
|
{
|
||||||
if (!class_exists('messenger'))
|
$email_method = $phpbb_container->get('messenger.method.email');
|
||||||
{
|
$email_method->set_use_queue(false);
|
||||||
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
}
|
|
||||||
|
|
||||||
$messenger = new messenger(false);
|
|
||||||
|
|
||||||
foreach ($inactive_users as $row)
|
foreach ($inactive_users as $row)
|
||||||
{
|
{
|
||||||
$messenger->template('admin_welcome_activated', $row['user_lang']);
|
$email_method->template('admin_welcome_activated', $row['user_lang']);
|
||||||
|
$email_method->set_addresses($row);
|
||||||
$messenger->set_addresses($row);
|
$email_method->anti_abuse_headers($config, $user);
|
||||||
|
$email_method->assign_vars([
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
'USERNAME' => html_entity_decode($row['username'], ENT_COMPAT),
|
||||||
|
]);
|
||||||
$messenger->assign_vars(array(
|
$email_method->send();
|
||||||
'USERNAME' => html_entity_decode($row['username'], ENT_COMPAT))
|
|
||||||
);
|
|
||||||
|
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$messenger->save_queue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($inactive_users))
|
if (!empty($inactive_users))
|
||||||
|
@ -204,39 +194,43 @@ class acp_inactive
|
||||||
|
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
/** @var \phpbb\di\service_collection */
|
||||||
|
$messenger = $phpbb_container->get('messenger.method_collection');
|
||||||
|
$messenger_collection_iterator = $messenger->getIterator();
|
||||||
|
|
||||||
if ($row = $db->sql_fetchrow($result))
|
if ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
// Send the messages
|
// Send the messages
|
||||||
if (!class_exists('messenger'))
|
|
||||||
{
|
|
||||||
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
}
|
|
||||||
|
|
||||||
$messenger = new messenger();
|
|
||||||
$usernames = $user_ids = array();
|
$usernames = $user_ids = array();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
$messenger->template('user_remind_inactive', $row['user_lang']);
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
|
{
|
||||||
$messenger->set_addresses($row);
|
if ($messenger_method->get_id() == $user_row['user_notify_type'] || $user_row['user_notify_type'] == $messenger_method::NOTIFY_BOTH)
|
||||||
|
{
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
$messenger_method->template('user_remind_inactive', $row['user_lang']);
|
||||||
|
$messenger_method->set_addresses($row);
|
||||||
$messenger->assign_vars(array(
|
$messenger_method->anti_abuse_headers($config, $user);
|
||||||
|
$messenger_method->assign_vars([
|
||||||
'USERNAME' => html_entity_decode($row['username'], ENT_COMPAT),
|
'USERNAME' => html_entity_decode($row['username'], ENT_COMPAT),
|
||||||
'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true),
|
'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true),
|
||||||
'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'])
|
'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'],
|
||||||
);
|
]);
|
||||||
|
|
||||||
$messenger->send($row['user_notify_type']);
|
$messenger_method->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$usernames[] = $row['username'];
|
$usernames[] = $row['username'];
|
||||||
$user_ids[] = (int) $row['user_id'];
|
$user_ids[] = (int) $row['user_id'];
|
||||||
}
|
}
|
||||||
while ($row = $db->sql_fetchrow($result));
|
while ($row = $db->sql_fetchrow($result));
|
||||||
|
|
||||||
$messenger->save_queue();
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
|
{
|
||||||
|
$messenger_method->save_queue();
|
||||||
|
}
|
||||||
|
|
||||||
// Add the remind state to the database and increase activation expiration by one day
|
// Add the remind state to the database and increase activation expiration by one day
|
||||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||||
|
|
|
@ -30,15 +30,12 @@ class acp_jabber
|
||||||
function main($id, $mode)
|
function main($id, $mode)
|
||||||
{
|
{
|
||||||
global $db, $user, $template, $phpbb_log, $request;
|
global $db, $user, $template, $phpbb_log, $request;
|
||||||
global $config, $phpbb_root_path, $phpEx;
|
global $config, $phpbb_container, $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
|
$jabber = $phpbb_container->get('messenger.method.jabber');
|
||||||
|
|
||||||
$user->add_lang('acp/board');
|
$user->add_lang('acp/board');
|
||||||
|
|
||||||
if (!class_exists('jabber'))
|
|
||||||
{
|
|
||||||
include($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);
|
|
||||||
}
|
|
||||||
|
|
||||||
$submit = (isset($_POST['submit'])) ? true : false;
|
$submit = (isset($_POST['submit'])) ? true : false;
|
||||||
|
|
||||||
if ($mode != 'settings')
|
if ($mode != 'settings')
|
||||||
|
@ -74,10 +71,8 @@ class acp_jabber
|
||||||
$log = 'JAB_SETTINGS_CHANGED';
|
$log = 'JAB_SETTINGS_CHANGED';
|
||||||
|
|
||||||
// Is this feature enabled? Then try to establish a connection
|
// Is this feature enabled? Then try to establish a connection
|
||||||
if ($jab_enable)
|
if ($jabber->is_enabled())
|
||||||
{
|
{
|
||||||
$jabber = new jabber($jab_host, $jab_port, $jab_username, $jab_password, $jab_use_ssl, $jab_verify_peer, $jab_verify_peer_name, $jab_allow_self_signed);
|
|
||||||
|
|
||||||
if (!$jabber->connect())
|
if (!$jabber->connect())
|
||||||
{
|
{
|
||||||
trigger_error($user->lang['ERR_JAB_CONNECT'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
|
trigger_error($user->lang['ERR_JAB_CONNECT'] . '<br /><br />' . $jabber->get_log() . adm_back_link($this->u_action), E_USER_WARNING);
|
||||||
|
@ -97,12 +92,12 @@ class acp_jabber
|
||||||
// We update the user table to be sure all users that have IM as notify type are set to both as notify type
|
// We update the user table to be sure all users that have IM as notify type are set to both as notify type
|
||||||
// We set this to both because users still have their jabber address entered and may want to receive jabber notifications again once it is re-enabled.
|
// We set this to both because users still have their jabber address entered and may want to receive jabber notifications again once it is re-enabled.
|
||||||
$sql_ary = array(
|
$sql_ary = array(
|
||||||
'user_notify_type' => NOTIFY_BOTH,
|
'user_notify_type' => $jabber::NOTIFY_BOTH,
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||||
WHERE user_notify_type = ' . NOTIFY_IM;
|
WHERE user_notify_type = ' . $jabber::NOTIFY_IM;
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +132,7 @@ class acp_jabber
|
||||||
'JAB_VERIFY_PEER' => $jab_verify_peer,
|
'JAB_VERIFY_PEER' => $jab_verify_peer,
|
||||||
'JAB_VERIFY_PEER_NAME' => $jab_verify_peer_name,
|
'JAB_VERIFY_PEER_NAME' => $jab_verify_peer_name,
|
||||||
'JAB_ALLOW_SELF_SIGNED' => $jab_allow_self_signed,
|
'JAB_ALLOW_SELF_SIGNED' => $jab_allow_self_signed,
|
||||||
'S_CAN_USE_SSL' => jabber::can_use_ssl(),
|
'S_CAN_USE_SSL' => $jabber::can_use_ssl(),
|
||||||
'S_GTALK_NOTE' => (!@function_exists('dns_get_record')) ? true : false,
|
'S_GTALK_NOTE' => (!@function_exists('dns_get_record')) ? true : false,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use phpbb\controller\helper;
|
use phpbb\controller\helper;
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
if (!defined('IN_PHPBB'))
|
if (!defined('IN_PHPBB'))
|
||||||
{
|
{
|
||||||
|
@ -364,11 +365,6 @@ class acp_users
|
||||||
|
|
||||||
if ($config['email_enable'])
|
if ($config['email_enable'])
|
||||||
{
|
{
|
||||||
if (!class_exists('messenger'))
|
|
||||||
{
|
|
||||||
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
}
|
|
||||||
|
|
||||||
$server_url = generate_board_url();
|
$server_url = generate_board_url();
|
||||||
|
|
||||||
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
||||||
|
@ -403,21 +399,17 @@ class acp_users
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
// Start sending email
|
// Start sending email
|
||||||
$messenger = new messenger(false);
|
$email_method = $phpbb_container->get('messenger.method.email');
|
||||||
|
$email_method->set_use_queue(false);
|
||||||
$messenger->template($email_template, $user_row['user_lang']);
|
$email_method->template($email_template, $user_row['user_lang']);
|
||||||
|
$email_method->set_addresses($user_row);
|
||||||
$messenger->set_addresses($user_row);
|
$email_method->anti_abuse_headers($config, $user);
|
||||||
|
$email_method->assign_vars([
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
|
||||||
|
|
||||||
$messenger->assign_vars(array(
|
|
||||||
'WELCOME_MSG' => html_entity_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), ENT_COMPAT),
|
'WELCOME_MSG' => html_entity_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), ENT_COMPAT),
|
||||||
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
||||||
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
|
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey",
|
||||||
);
|
]);
|
||||||
|
$email_method->send();
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
|
||||||
|
|
||||||
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_REACTIVATE', false, array($user_row['username']));
|
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_REACTIVATE', false, array($user_row['username']));
|
||||||
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_REACTIVATE_USER', false, array(
|
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_REACTIVATE_USER', false, array(
|
||||||
|
@ -462,24 +454,15 @@ class acp_users
|
||||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||||
$phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']);
|
$phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']);
|
||||||
|
|
||||||
if (!class_exists('messenger'))
|
$email_method = $phpbb_container->get('messenger.method.email');
|
||||||
{
|
$email_method->set_use_queue(false);
|
||||||
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
$email_method->template('admin_welcome_activated', $user_row['user_lang']);
|
||||||
}
|
$email_method->set_addresses($user_row);
|
||||||
|
$email_method->anti_abuse_headers($config, $user);
|
||||||
$messenger = new messenger(false);
|
$email_method->assign_vars([
|
||||||
|
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
||||||
$messenger->template('admin_welcome_activated', $user_row['user_lang']);
|
]);
|
||||||
|
$email_method->send();
|
||||||
$messenger->set_addresses($user_row);
|
|
||||||
|
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
|
||||||
|
|
||||||
$messenger->assign_vars(array(
|
|
||||||
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT))
|
|
||||||
);
|
|
||||||
|
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1810,9 +1793,9 @@ class acp_users
|
||||||
'MASS_EMAIL' => $data['massemail'],
|
'MASS_EMAIL' => $data['massemail'],
|
||||||
'ALLOW_PM' => $data['allowpm'],
|
'ALLOW_PM' => $data['allowpm'],
|
||||||
'HIDE_ONLINE' => $data['hideonline'],
|
'HIDE_ONLINE' => $data['hideonline'],
|
||||||
'NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false,
|
'NOTIFY_EMAIL' => ($data['notifymethod'] == messenger_interface::NOTIFY_EMAIL) ? true : false,
|
||||||
'NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false,
|
'NOTIFY_IM' => ($data['notifymethod'] == messenger_interface::NOTIFY_IM) ? true : false,
|
||||||
'NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false,
|
'NOTIFY_BOTH' => ($data['notifymethod'] == messenger_interface::NOTIFY_BOTH) ? true : false,
|
||||||
'NOTIFY_PM' => $data['notifypm'],
|
'NOTIFY_PM' => $data['notifypm'],
|
||||||
'BBCODE' => $data['bbcode'],
|
'BBCODE' => $data['bbcode'],
|
||||||
'SMILIES' => $data['smilies'],
|
'SMILIES' => $data['smilies'],
|
||||||
|
|
|
@ -120,8 +120,11 @@ define('POST_ANNOUNCE', 2);
|
||||||
define('POST_GLOBAL', 3);
|
define('POST_GLOBAL', 3);
|
||||||
|
|
||||||
// Notify methods
|
// Notify methods
|
||||||
|
/** @deprecated 4.0.0-a1 Replaced by \phpbb\messenger\method\messenger_interface::NOTIFY_EMAIL, to be removed in 5.0.0-a1 */
|
||||||
define('NOTIFY_EMAIL', 0);
|
define('NOTIFY_EMAIL', 0);
|
||||||
|
/** @deprecated 4.0.0-a1 Replaced by \phpbb\messenger\method\messenger_interface::NOTIFY_IM, to be removed in 5.0.0-a1 */
|
||||||
define('NOTIFY_IM', 1);
|
define('NOTIFY_IM', 1);
|
||||||
|
/** @deprecated 4.0.0-a1 Replaced by \phpbb\messenger\method\messenger_interface::NOTIFY_BOTH, to be removed in 5.0.0-a1 */
|
||||||
define('NOTIFY_BOTH', 2);
|
define('NOTIFY_BOTH', 2);
|
||||||
|
|
||||||
// Notify status
|
// Notify status
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,6 +11,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
|
@ -244,7 +246,7 @@ function user_add($user_row, $cp_data = false, $notifications_data = null)
|
||||||
|
|
||||||
'user_notify' => 0,
|
'user_notify' => 0,
|
||||||
'user_notify_pm' => 1,
|
'user_notify_pm' => 1,
|
||||||
'user_notify_type' => NOTIFY_EMAIL,
|
'user_notify_type' => messenger_interface::NOTIFY_EMAIL,
|
||||||
'user_allow_pm' => 1,
|
'user_allow_pm' => 1,
|
||||||
'user_allow_viewonline' => 1,
|
'user_allow_viewonline' => 1,
|
||||||
'user_allow_viewemail' => 1,
|
'user_allow_viewemail' => 1,
|
||||||
|
|
|
@ -51,8 +51,6 @@ class mcp_pm_reports
|
||||||
{
|
{
|
||||||
case 'close':
|
case 'close':
|
||||||
case 'delete':
|
case 'delete':
|
||||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
|
|
||||||
$report_id_list = $request->variable('report_id_list', array(0));
|
$report_id_list = $request->variable('report_id_list', array(0));
|
||||||
|
|
||||||
if (!count($report_id_list))
|
if (!count($report_id_list))
|
||||||
|
|
|
@ -50,8 +50,6 @@ class mcp_queue
|
||||||
{
|
{
|
||||||
case 'approve':
|
case 'approve':
|
||||||
case 'restore':
|
case 'restore':
|
||||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
|
|
||||||
$post_id_list = $request->variable('post_id_list', array(0));
|
$post_id_list = $request->variable('post_id_list', array(0));
|
||||||
$topic_id_list = $request->variable('topic_id_list', array(0));
|
$topic_id_list = $request->variable('topic_id_list', array(0));
|
||||||
|
|
||||||
|
@ -113,11 +111,6 @@ class mcp_queue
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!class_exists('messenger'))
|
|
||||||
{
|
|
||||||
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($topic_id_list))
|
if (!empty($topic_id_list))
|
||||||
{
|
{
|
||||||
$post_visibility = ($mode == 'deleted_topics') ? ITEM_DELETED : array(ITEM_UNAPPROVED, ITEM_REAPPROVE);
|
$post_visibility = ($mode == 'deleted_topics') ? ITEM_DELETED : array(ITEM_UNAPPROVED, ITEM_REAPPROVE);
|
||||||
|
|
|
@ -49,8 +49,6 @@ class mcp_reports
|
||||||
{
|
{
|
||||||
case 'close':
|
case 'close':
|
||||||
case 'delete':
|
case 'delete':
|
||||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
|
|
||||||
$report_id_list = $request->variable('report_id_list', array(0));
|
$report_id_list = $request->variable('report_id_list', array(0));
|
||||||
|
|
||||||
if (!count($report_id_list))
|
if (!count($report_id_list))
|
||||||
|
|
|
@ -107,7 +107,6 @@ function mcp_topic_view($id, $mode, $action)
|
||||||
}
|
}
|
||||||
|
|
||||||
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
||||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
|
|
||||||
if (!count($post_id_list))
|
if (!count($post_id_list))
|
||||||
{
|
{
|
||||||
|
|
|
@ -435,7 +435,6 @@ class phpbb_questionnaire_phpbb_data_provider
|
||||||
'secure_downloads' => true,
|
'secure_downloads' => true,
|
||||||
'session_gc' => true,
|
'session_gc' => true,
|
||||||
'session_length' => true,
|
'session_length' => true,
|
||||||
'smtp_auth_method' => true,
|
|
||||||
'smtp_delivery' => true,
|
'smtp_delivery' => true,
|
||||||
'topics_per_page' => true,
|
'topics_per_page' => true,
|
||||||
'version' => true,
|
'version' => true,
|
||||||
|
|
|
@ -131,21 +131,23 @@ class ucp_activate
|
||||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||||
$phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']);
|
$phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']);
|
||||||
|
|
||||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
$messenger = $phpbb_container->get('messenger.method_collection');
|
||||||
|
$messenger_collection_iterator = $messenger->getIterator();
|
||||||
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
|
{
|
||||||
|
if ($messenger_method->get_id() == $user_row['user_notify_type'] || $user_row['user_notify_type'] == $messenger_method::NOTIFY_BOTH)
|
||||||
|
{
|
||||||
|
$messenger_method->set_use_queue(false);
|
||||||
|
$messenger_method->template('admin_welcome_activated', $user_row['user_lang']);
|
||||||
|
$messenger_method->set_addresses($user_row);
|
||||||
|
$messenger_method->anti_abuse_headers($config, $user);
|
||||||
|
$messenger_method->assign_vars([
|
||||||
|
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
||||||
|
]);
|
||||||
|
|
||||||
$messenger = new messenger(false);
|
$messenger_method->send();
|
||||||
|
}
|
||||||
$messenger->template('admin_welcome_activated', $user_row['user_lang']);
|
}
|
||||||
|
|
||||||
$messenger->set_addresses($user_row);
|
|
||||||
|
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
|
||||||
|
|
||||||
$messenger->assign_vars(array(
|
|
||||||
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT))
|
|
||||||
);
|
|
||||||
|
|
||||||
$messenger->send($user_row['user_notify_type']);
|
|
||||||
|
|
||||||
$message = 'ACCOUNT_ACTIVE_ADMIN';
|
$message = 'ACCOUNT_ACTIVE_ADMIN';
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
|
@ -52,10 +54,10 @@ class ucp_prefs
|
||||||
'allowpm' => $request->variable('allowpm', (bool) $user->data['user_allow_pm']),
|
'allowpm' => $request->variable('allowpm', (bool) $user->data['user_allow_pm']),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($data['notifymethod'] == NOTIFY_IM && (!$config['jab_enable'] || !$user->data['user_jabber'] || !@extension_loaded('xml')))
|
if ($data['notifymethod'] == messenger_interface::NOTIFY_IM && (!$config['jab_enable'] || !$user->data['user_jabber'] || !@extension_loaded('xml')))
|
||||||
{
|
{
|
||||||
// Jabber isnt enabled, or no jabber field filled in. Update the users table to be sure its correct.
|
// Jabber isnt enabled, or no jabber field filled in. Update the users table to be sure its correct.
|
||||||
$data['notifymethod'] = NOTIFY_BOTH;
|
$data['notifymethod'] = messenger_interface::NOTIFY_BOTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,9 +184,9 @@ class ucp_prefs
|
||||||
$template->assign_vars([
|
$template->assign_vars([
|
||||||
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
||||||
|
|
||||||
'S_NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false,
|
'S_NOTIFY_EMAIL' => ($data['notifymethod'] == messenger_interface::NOTIFY_EMAIL) ? true : false,
|
||||||
'S_NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false,
|
'S_NOTIFY_IM' => ($data['notifymethod'] == messenger_interface::NOTIFY_IM) ? true : false,
|
||||||
'S_NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false,
|
'S_NOTIFY_BOTH' => ($data['notifymethod'] == messenger_interface::NOTIFY_BOTH) ? true : false,
|
||||||
'S_VIEW_EMAIL' => $data['viewemail'],
|
'S_VIEW_EMAIL' => $data['viewemail'],
|
||||||
'S_MASS_EMAIL' => $data['massemail'],
|
'S_MASS_EMAIL' => $data['massemail'],
|
||||||
'S_ALLOW_PM' => $data['allowpm'],
|
'S_ALLOW_PM' => $data['allowpm'],
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
|
@ -170,27 +172,20 @@ class ucp_profile
|
||||||
{
|
{
|
||||||
$message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
|
$message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
|
||||||
|
|
||||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
|
|
||||||
$server_url = generate_board_url();
|
$server_url = generate_board_url();
|
||||||
|
|
||||||
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
||||||
|
|
||||||
$messenger = new messenger(false);
|
$email_method = $phpbb_container->get('messenger.method.email');
|
||||||
|
|
||||||
$template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate';
|
$template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate';
|
||||||
$messenger->template($template_file, $user->data['user_lang']);
|
$email_method->template($template_file, $user->data['user_lang']);
|
||||||
|
$email_method->to($data['email'], $data['username']);
|
||||||
$messenger->to($data['email'], $data['username']);
|
$email_method->anti_abuse_headers($config, $user);
|
||||||
|
$email_method->assign_vars([
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
|
||||||
|
|
||||||
$messenger->assign_vars(array(
|
|
||||||
'USERNAME' => html_entity_decode($data['username'], ENT_COMPAT),
|
'USERNAME' => html_entity_decode($data['username'], ENT_COMPAT),
|
||||||
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
|
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey",
|
||||||
);
|
]);
|
||||||
|
$email_method->send();
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
|
||||||
|
|
||||||
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
||||||
{
|
{
|
||||||
|
@ -370,11 +365,11 @@ class ucp_profile
|
||||||
{
|
{
|
||||||
$data['notify'] = $user->data['user_notify_type'];
|
$data['notify'] = $user->data['user_notify_type'];
|
||||||
|
|
||||||
if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml')))
|
if ($data['notify'] == messenger_interface::NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml')))
|
||||||
{
|
{
|
||||||
// User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
|
// User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
|
||||||
// Disable notify by Jabber now for this user.
|
// Disable notify by Jabber now for this user.
|
||||||
$data['notify'] = NOTIFY_EMAIL;
|
$data['notify'] = messenger_interface::NOTIFY_EMAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_ary = array(
|
$sql_ary = array(
|
||||||
|
|
|
@ -458,30 +458,26 @@ class ucp_register
|
||||||
|
|
||||||
if ($config['email_enable'])
|
if ($config['email_enable'])
|
||||||
{
|
{
|
||||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
/** var \phpbb\messenger\method\email */
|
||||||
|
$email_method = $phpbb_container->get('messenger.method.email');
|
||||||
$messenger = new messenger(false);
|
$email_method->set_use_queue(false);
|
||||||
|
$email_method->template($email_template, $data['lang']);
|
||||||
$messenger->template($email_template, $data['lang']);
|
$email_method->to($data['email'], $data['username']);
|
||||||
|
$email_method->anti_abuse_headers($config, $user);
|
||||||
$messenger->to($data['email'], $data['username']);
|
$email_method->assign_vars([
|
||||||
|
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
|
||||||
|
|
||||||
$messenger->assign_vars(array(
|
|
||||||
'WELCOME_MSG' => html_entity_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), ENT_COMPAT),
|
'WELCOME_MSG' => html_entity_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), ENT_COMPAT),
|
||||||
'USERNAME' => html_entity_decode($data['username'], ENT_COMPAT),
|
'USERNAME' => html_entity_decode($data['username'], ENT_COMPAT),
|
||||||
'PASSWORD' => html_entity_decode($data['new_password'], ENT_COMPAT),
|
'PASSWORD' => html_entity_decode($data['new_password'], ENT_COMPAT),
|
||||||
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey")
|
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey",
|
||||||
);
|
]);
|
||||||
|
|
||||||
if ($coppa)
|
if ($coppa)
|
||||||
{
|
{
|
||||||
$messenger->assign_vars(array(
|
$email_method->assign_vars([
|
||||||
'FAX_INFO' => $config['coppa_fax'],
|
'FAX_INFO' => $config['coppa_fax'],
|
||||||
'MAIL_INFO' => $config['coppa_mail'],
|
'MAIL_INFO' => $config['coppa_mail'],
|
||||||
'EMAIL_ADDRESS' => $data['email'])
|
'EMAIL_ADDRESS' => $data['email'],
|
||||||
);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -495,8 +491,9 @@ class ucp_register
|
||||||
* @var string server_url Server URL
|
* @var string server_url Server URL
|
||||||
* @var int user_id New user ID
|
* @var int user_id New user ID
|
||||||
* @var string user_actkey User activation key
|
* @var string user_actkey User activation key
|
||||||
* @var messenger messenger phpBB Messenger
|
* @var \phpbb\messenger\method\email email_method phpBB email notification method
|
||||||
* @since 3.2.4-RC1
|
* @since 3.2.4-RC1
|
||||||
|
* @changed 4.0.0-a1 Added vars: email_method. Removed vars: messenger.
|
||||||
*/
|
*/
|
||||||
$vars = array(
|
$vars = array(
|
||||||
'user_row',
|
'user_row',
|
||||||
|
@ -506,11 +503,11 @@ class ucp_register
|
||||||
'server_url',
|
'server_url',
|
||||||
'user_id',
|
'user_id',
|
||||||
'user_actkey',
|
'user_actkey',
|
||||||
'messenger',
|
'email_method',
|
||||||
);
|
);
|
||||||
extract($phpbb_dispatcher->trigger_event('core.ucp_register_welcome_email_before', compact($vars)));
|
extract($phpbb_dispatcher->trigger_event('core.ucp_register_welcome_email_before', compact($vars)));
|
||||||
|
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
$email_method->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
||||||
|
|
|
@ -30,7 +30,7 @@ class ucp_resend
|
||||||
function main($id, $mode)
|
function main($id, $mode)
|
||||||
{
|
{
|
||||||
global $config, $phpbb_root_path, $phpEx;
|
global $config, $phpbb_root_path, $phpEx;
|
||||||
global $db, $user, $auth, $template, $request;
|
global $db, $user, $auth, $template, $request, $phpbb_container;
|
||||||
|
|
||||||
$username = $request->variable('username', '', true);
|
$username = $request->variable('username', '', true);
|
||||||
$email = strtolower($request->variable('email', ''));
|
$email = strtolower($request->variable('email', ''));
|
||||||
|
@ -92,34 +92,35 @@ class ucp_resend
|
||||||
trigger_error('NO_GROUP');
|
trigger_error('NO_GROUP');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$board_url = generate_board_url();
|
||||||
$coppa = ($row['group_name'] == 'REGISTERED_COPPA' && $row['group_type'] == GROUP_SPECIAL) ? true : false;
|
$coppa = ($row['group_name'] == 'REGISTERED_COPPA' && $row['group_type'] == GROUP_SPECIAL) ? true : false;
|
||||||
|
|
||||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
$email_method = $phpbb_container->get('messenger.method.email');
|
||||||
$messenger = new messenger(false);
|
$email_method->set_use_queue(false);
|
||||||
|
|
||||||
if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa)
|
if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa)
|
||||||
{
|
{
|
||||||
$messenger->template(($coppa) ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']);
|
$email_method->template(($coppa) ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']);
|
||||||
$messenger->set_addresses($user_row);
|
$email_method->set_addresses($user_row);
|
||||||
|
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
$email_method->anti_abuse_headers($config, $user);
|
||||||
|
|
||||||
$messenger->assign_vars(array(
|
$email_method->assign_vars([
|
||||||
'WELCOME_MSG' => html_entity_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), ENT_COMPAT),
|
'WELCOME_MSG' => html_entity_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), ENT_COMPAT),
|
||||||
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
||||||
'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
|
'U_ACTIVATE' => $board_url . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}",
|
||||||
);
|
]);
|
||||||
|
|
||||||
if ($coppa)
|
if ($coppa)
|
||||||
{
|
{
|
||||||
$messenger->assign_vars(array(
|
$email_method->assign_vars([
|
||||||
'FAX_INFO' => $config['coppa_fax'],
|
'FAX_INFO' => $config['coppa_fax'],
|
||||||
'MAIL_INFO' => $config['coppa_mail'],
|
'MAIL_INFO' => $config['coppa_mail'],
|
||||||
'EMAIL_ADDRESS' => $user_row['user_email'])
|
'EMAIL_ADDRESS' => $user_row['user_email'],
|
||||||
);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
$email_method->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
||||||
|
@ -132,22 +133,36 @@ class ucp_resend
|
||||||
WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']);
|
WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
/** @var \phpbb\di\service_collection */
|
||||||
|
$messenger = $phpbb_container->get('messenger.method_collection');
|
||||||
|
$messenger_collection_iterator = $messenger->getIterator();
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$messenger->template('admin_activate', $row['user_lang']);
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
$messenger->set_addresses($row);
|
{
|
||||||
|
$messenger_method->set_use_queue(false);
|
||||||
$messenger->anti_abuse_headers($config, $user);
|
if ($messenger_method->get_id() == $row['user_notify_type'] || $row['user_notify_type'] == $messenger_method::NOTIFY_BOTH)
|
||||||
|
{
|
||||||
$messenger->assign_vars(array(
|
$messenger_method->template('admin_activate', $row['user_lang']);
|
||||||
|
$messenger_method->set_addresses($row);
|
||||||
|
$messenger_method->anti_abuse_headers($config, $user);
|
||||||
|
$messenger_method->assign_vars([
|
||||||
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
||||||
'U_USER_DETAILS' => generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}",
|
'U_USER_DETAILS' => $board_url . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}",
|
||||||
'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
|
'U_ACTIVATE' => $board_url . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}",
|
||||||
);
|
]);
|
||||||
|
|
||||||
$messenger->send($row['user_notify_type']);
|
$messenger_method->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// Save the queue in the messenger method class (has to be called or these messages could be lost)
|
||||||
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
|
{
|
||||||
|
$messenger_method->save_queue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->update_activation_expiration();
|
$this->update_activation_expiration();
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE to potential convertor authors. Please use this file to get
|
* NOTE to potential convertor authors. Please use this file to get
|
||||||
* familiar with the structure since we added some bare explanations here.
|
* familiar with the structure since we added some bare explanations here.
|
||||||
|
@ -936,7 +938,7 @@ if (!$get_info)
|
||||||
array('user_emailtime', 'users.user_emailtime', 'null_to_zero'),
|
array('user_emailtime', 'users.user_emailtime', 'null_to_zero'),
|
||||||
array('user_notify', 'users.user_notify', 'intval'),
|
array('user_notify', 'users.user_notify', 'intval'),
|
||||||
array('user_notify_pm', 'users.user_notify_pm', 'intval'),
|
array('user_notify_pm', 'users.user_notify_pm', 'intval'),
|
||||||
array('user_notify_type', NOTIFY_EMAIL, ''),
|
array('user_notify_type', $messenger_method::NOTIFY_EMAIL, ''),
|
||||||
array('user_allow_pm', 'users.user_allow_pm', 'intval'),
|
array('user_allow_pm', 'users.user_allow_pm', 'intval'),
|
||||||
array('user_allow_viewonline', 'users.user_allow_viewonline', 'intval'),
|
array('user_allow_viewonline', 'users.user_allow_viewonline', 'intval'),
|
||||||
array('user_allow_viewemail', 'users.user_viewemail', 'intval'),
|
array('user_allow_viewemail', 'users.user_viewemail', 'intval'),
|
||||||
|
|
|
@ -287,7 +287,6 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('sitename_short', '
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_path', 'images/smilies');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_path', 'images/smilies');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_per_page', '50');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_per_page', '50');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_allow_self_signed', '0');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_allow_self_signed', '0');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_auth_method', 'PLAIN');
|
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_delivery', '0');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_delivery', '0');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_host', '');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_host', '');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_port', '25');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_port', '25');
|
||||||
|
|
|
@ -553,15 +553,8 @@ $lang = array_merge($lang, array(
|
||||||
'SEND_TEST_EMAIL_EXPLAIN' => 'This will send a test email to the address defined in your account.',
|
'SEND_TEST_EMAIL_EXPLAIN' => 'This will send a test email to the address defined in your account.',
|
||||||
'SMTP_ALLOW_SELF_SIGNED' => 'Allow self-signed SSL certificates',
|
'SMTP_ALLOW_SELF_SIGNED' => 'Allow self-signed SSL certificates',
|
||||||
'SMTP_ALLOW_SELF_SIGNED_EXPLAIN'=> 'Allow connections to SMTP server with self-signed SSL certificate. <br><em><strong>Warning:</strong> Allowing self-signed SSL certificates may cause security implications.</em>',
|
'SMTP_ALLOW_SELF_SIGNED_EXPLAIN'=> 'Allow connections to SMTP server with self-signed SSL certificate. <br><em><strong>Warning:</strong> Allowing self-signed SSL certificates may cause security implications.</em>',
|
||||||
'SMTP_AUTH_METHOD' => 'Authentication method for SMTP',
|
|
||||||
'SMTP_AUTH_METHOD_EXPLAIN' => 'Only used if a username/password is set, ask your provider if you are unsure which method to use.',
|
|
||||||
'SMTP_CRAM_MD5' => 'CRAM-MD5',
|
|
||||||
'SMTP_DIGEST_MD5' => 'DIGEST-MD5',
|
|
||||||
'SMTP_LOGIN' => 'LOGIN',
|
|
||||||
'SMTP_PASSWORD' => 'SMTP password',
|
'SMTP_PASSWORD' => 'SMTP password',
|
||||||
'SMTP_PASSWORD_EXPLAIN' => 'Only enter a password if your SMTP server requires it.<br><em><strong>Warning:</strong> This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.</em>',
|
'SMTP_PASSWORD_EXPLAIN' => 'Only enter a password if your SMTP server requires it.<br><em><strong>Warning:</strong> This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.</em>',
|
||||||
'SMTP_PLAIN' => 'PLAIN',
|
|
||||||
'SMTP_POP_BEFORE_SMTP' => 'POP-BEFORE-SMTP',
|
|
||||||
'SMTP_PORT' => 'SMTP server port',
|
'SMTP_PORT' => 'SMTP server port',
|
||||||
'SMTP_PORT_EXPLAIN' => 'Only change this if you know your SMTP server is on a different port.',
|
'SMTP_PORT_EXPLAIN' => 'Only change this if you know your SMTP server is on a different port.',
|
||||||
'SMTP_SERVER' => 'SMTP server address',
|
'SMTP_SERVER' => 'SMTP server address',
|
||||||
|
|
|
@ -428,8 +428,6 @@ switch ($mode)
|
||||||
if (check_form_key('memberlist_messaging'))
|
if (check_form_key('memberlist_messaging'))
|
||||||
{
|
{
|
||||||
|
|
||||||
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
|
|
||||||
$subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']);
|
$subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']);
|
||||||
$message = $request->variable('message', '', true);
|
$message = $request->variable('message', '', true);
|
||||||
|
|
||||||
|
@ -438,22 +436,21 @@ switch ($mode)
|
||||||
trigger_error('EMPTY_MESSAGE_IM');
|
trigger_error('EMPTY_MESSAGE_IM');
|
||||||
}
|
}
|
||||||
|
|
||||||
$messenger = new messenger(false);
|
$jabber = $phpbb_container->get('messenger.method.jabber');
|
||||||
|
$jabber->set_use_queue(false);
|
||||||
|
|
||||||
$messenger->template('profile_send_im', $row['user_lang']);
|
$jabber->template('profile_send_im', $row['user_lang']);
|
||||||
$messenger->subject(html_entity_decode($subject, ENT_COMPAT));
|
$jabber->subject(html_entity_decode($subject, ENT_COMPAT));
|
||||||
|
$jabber->set_addresses($row);
|
||||||
|
|
||||||
$messenger->replyto($user->data['user_email']);
|
$jabber->assign_vars([
|
||||||
$messenger->set_addresses($row);
|
|
||||||
|
|
||||||
$messenger->assign_vars(array(
|
|
||||||
'BOARD_CONTACT' => phpbb_get_board_contact($config, $phpEx),
|
'BOARD_CONTACT' => phpbb_get_board_contact($config, $phpEx),
|
||||||
'FROM_USERNAME' => html_entity_decode($user->data['username'], ENT_COMPAT),
|
'FROM_USERNAME' => html_entity_decode($user->data['username'], ENT_COMPAT),
|
||||||
'TO_USERNAME' => html_entity_decode($row['username'], ENT_COMPAT),
|
'TO_USERNAME' => html_entity_decode($row['username'], ENT_COMPAT),
|
||||||
'MESSAGE' => html_entity_decode($message, ENT_COMPAT))
|
'MESSAGE' => html_entity_decode($message, ENT_COMPAT),
|
||||||
);
|
]);
|
||||||
|
|
||||||
$messenger->send(NOTIFY_IM);
|
$jabber->send();
|
||||||
|
|
||||||
$s_select = 'S_SENT_JABBER';
|
$s_select = 'S_SENT_JABBER';
|
||||||
}
|
}
|
||||||
|
@ -903,10 +900,7 @@ switch ($mode)
|
||||||
|
|
||||||
case 'contactadmin':
|
case 'contactadmin':
|
||||||
case 'email':
|
case 'email':
|
||||||
if (!class_exists('messenger'))
|
$messenger = $phpbb_container->get('messenger.method_collection');
|
||||||
{
|
|
||||||
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
}
|
|
||||||
|
|
||||||
$user_id = $request->variable('u', 0);
|
$user_id = $request->variable('u', 0);
|
||||||
$topic_id = $request->variable('t', 0);
|
$topic_id = $request->variable('t', 0);
|
||||||
|
@ -940,7 +934,6 @@ switch ($mode)
|
||||||
|
|
||||||
if ($request->is_set_post('submit'))
|
if ($request->is_set_post('submit'))
|
||||||
{
|
{
|
||||||
$messenger = new messenger(false);
|
|
||||||
$form->submit($messenger);
|
$form->submit($messenger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ use phpbb\config\config;
|
||||||
use phpbb\console\command\command;
|
use phpbb\console\command\command;
|
||||||
use phpbb\language\language;
|
use phpbb\language\language;
|
||||||
use phpbb\log\log_interface;
|
use phpbb\log\log_interface;
|
||||||
|
use phpbb\messenger\method\email;
|
||||||
use phpbb\notification\manager;
|
use phpbb\notification\manager;
|
||||||
use phpbb\user;
|
use phpbb\user;
|
||||||
use phpbb\user_loader;
|
use phpbb\user_loader;
|
||||||
|
@ -32,6 +33,9 @@ class activate extends command
|
||||||
/** @var config */
|
/** @var config */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
/** @var email */
|
||||||
|
protected $email_method;
|
||||||
|
|
||||||
/** @var language */
|
/** @var language */
|
||||||
protected $language;
|
protected $language;
|
||||||
|
|
||||||
|
@ -65,14 +69,16 @@ class activate extends command
|
||||||
* @param config $config
|
* @param config $config
|
||||||
* @param language $language
|
* @param language $language
|
||||||
* @param log_interface $log
|
* @param log_interface $log
|
||||||
|
* @param email $email_method
|
||||||
* @param manager $notifications
|
* @param manager $notifications
|
||||||
* @param user_loader $user_loader
|
* @param user_loader $user_loader
|
||||||
* @param string $phpbb_root_path
|
* @param string $phpbb_root_path
|
||||||
* @param string $php_ext
|
* @param string $php_ext
|
||||||
*/
|
*/
|
||||||
public function __construct(user $user, config $config, language $language, log_interface $log, manager $notifications, user_loader $user_loader, $phpbb_root_path, $php_ext)
|
public function __construct(user $user, config $config, language $language, log_interface $log, email $email_method, manager $notifications, user_loader $user_loader, $phpbb_root_path, $php_ext)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
$this->email_method = $email_method;
|
||||||
$this->language = $language;
|
$this->language = $language;
|
||||||
$this->log = $log;
|
$this->log = $log;
|
||||||
$this->notifications = $notifications;
|
$this->notifications = $notifications;
|
||||||
|
@ -194,20 +200,14 @@ class activate extends command
|
||||||
|
|
||||||
if ($input->getOption('send-email'))
|
if ($input->getOption('send-email'))
|
||||||
{
|
{
|
||||||
if (!class_exists('messenger'))
|
$this->email_method->set_use_queue(false);
|
||||||
{
|
$this->email_method->template('admin_welcome_activated', $user_row['user_lang']);
|
||||||
require($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
|
$this->email_method->set_addresses($user_row);
|
||||||
}
|
$this->email_method->anti_abuse_headers($this->config, $this->user);
|
||||||
|
$this->email_method->assign_vars([
|
||||||
$messenger = new \messenger(false);
|
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
||||||
$messenger->template('admin_welcome_activated', $user_row['user_lang']);
|
]);
|
||||||
$messenger->set_addresses($user_row);
|
$this->email_method->send();
|
||||||
$messenger->anti_abuse_headers($this->config, $this->user);
|
|
||||||
$messenger->assign_vars(array(
|
|
||||||
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT))
|
|
||||||
);
|
|
||||||
|
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ use phpbb\console\command\command;
|
||||||
use phpbb\db\driver\driver_interface;
|
use phpbb\db\driver\driver_interface;
|
||||||
use phpbb\exception\runtime_exception;
|
use phpbb\exception\runtime_exception;
|
||||||
use phpbb\language\language;
|
use phpbb\language\language;
|
||||||
|
use phpbb\messenger\method\email;
|
||||||
use phpbb\passwords\manager;
|
use phpbb\passwords\manager;
|
||||||
use phpbb\user;
|
use phpbb\user;
|
||||||
use Symfony\Component\Console\Command\Command as symfony_command;
|
use Symfony\Component\Console\Command\Command as symfony_command;
|
||||||
|
@ -39,6 +40,9 @@ class add extends command
|
||||||
/** @var config */
|
/** @var config */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
/** @var email */
|
||||||
|
protected $email_method;
|
||||||
|
|
||||||
/** @var language */
|
/** @var language */
|
||||||
protected $language;
|
protected $language;
|
||||||
|
|
||||||
|
@ -66,14 +70,16 @@ class add extends command
|
||||||
* @param driver_interface $db
|
* @param driver_interface $db
|
||||||
* @param config $config
|
* @param config $config
|
||||||
* @param language $language
|
* @param language $language
|
||||||
|
* @param service_collection $messenger
|
||||||
* @param manager $password_manager
|
* @param manager $password_manager
|
||||||
* @param string $phpbb_root_path
|
* @param string $phpbb_root_path
|
||||||
* @param string $php_ext
|
* @param string $php_ext
|
||||||
*/
|
*/
|
||||||
public function __construct(user $user, driver_interface $db, config $config, language $language, manager $password_manager, $phpbb_root_path, $php_ext)
|
public function __construct(user $user, driver_interface $db, config $config, language $language, email $email_method, manager $password_manager, $phpbb_root_path, $php_ext)
|
||||||
{
|
{
|
||||||
$this->db = $db;
|
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
$this->db = $db;
|
||||||
|
$this->email_method = $email_method;
|
||||||
$this->language = $language;
|
$this->language = $language;
|
||||||
$this->password_manager = $password_manager;
|
$this->password_manager = $password_manager;
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
|
@ -307,23 +313,17 @@ class add extends command
|
||||||
|
|
||||||
$user_actkey = $this->get_activation_key($user_id);
|
$user_actkey = $this->get_activation_key($user_id);
|
||||||
|
|
||||||
if (!class_exists('messenger'))
|
$this->email_method->set_use_queue(false);
|
||||||
{
|
$this->email_method->template($email_template, $this->user->lang_name);
|
||||||
require($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
|
$this->email_method->to($this->data['email'], $this->data['username']);
|
||||||
}
|
$this->email_method->anti_abuse_headers($this->config, $this->user);
|
||||||
|
$this->email_method->assign_vars([
|
||||||
$messenger = new \messenger(false);
|
|
||||||
$messenger->template($email_template, $this->user->lang_name);
|
|
||||||
$messenger->to($this->data['email'], $this->data['username']);
|
|
||||||
$messenger->anti_abuse_headers($this->config, $this->user);
|
|
||||||
$messenger->assign_vars(array(
|
|
||||||
'WELCOME_MSG' => html_entity_decode($this->language->lang('WELCOME_SUBJECT', $this->config['sitename']), ENT_COMPAT),
|
'WELCOME_MSG' => html_entity_decode($this->language->lang('WELCOME_SUBJECT', $this->config['sitename']), ENT_COMPAT),
|
||||||
'USERNAME' => html_entity_decode($this->data['username'], ENT_COMPAT),
|
'USERNAME' => html_entity_decode($this->data['username'], ENT_COMPAT),
|
||||||
'PASSWORD' => html_entity_decode($this->data['new_password'], ENT_COMPAT),
|
'PASSWORD' => html_entity_decode($this->data['new_password'], ENT_COMPAT),
|
||||||
'U_ACTIVATE' => generate_board_url() . "/ucp.{$this->php_ext}?mode=activate&u=$user_id&k=$user_actkey")
|
'U_ACTIVATE' => generate_board_url() . "/ucp.{$this->php_ext}?mode=activate&u=$user_id&k=$user_actkey",
|
||||||
);
|
]);
|
||||||
|
$this->email_method->send();
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,30 +13,34 @@
|
||||||
|
|
||||||
namespace phpbb\cron\task\core;
|
namespace phpbb\cron\task\core;
|
||||||
|
|
||||||
|
use phpbb\config\config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue cron task. Sends email and jabber messages queued by other scripts.
|
* Queue cron task. Sends email and jabber messages queued by other scripts.
|
||||||
*/
|
*/
|
||||||
class queue extends \phpbb\cron\task\base
|
class queue extends \phpbb\cron\task\base
|
||||||
{
|
{
|
||||||
protected $phpbb_root_path;
|
/** var config */
|
||||||
protected $php_ext;
|
|
||||||
protected $cache_dir;
|
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
/** var \phpbb\messenger\queue */
|
||||||
|
protected $queue;
|
||||||
|
|
||||||
|
/** var string */
|
||||||
|
protected $queue_cache_file;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param string $phpbb_root_path The root path
|
* @param config $config The config
|
||||||
* @param string $php_ext PHP file extension
|
* @param string $queue_cache_file The messenger file queue cache filename
|
||||||
* @param \phpbb\config\config $config The config
|
* @param \phpbb\messenger\queue $queue The messenger file queue object
|
||||||
* @param string $cache_dir phpBB cache directory
|
|
||||||
*/
|
*/
|
||||||
public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, $cache_dir)
|
public function __construct(config $config, \phpbb\messenger\queue $queue, $queue_cache_file)
|
||||||
{
|
{
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
|
||||||
$this->php_ext = $php_ext;
|
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->cache_dir = $cache_dir;
|
$this->queue = $queue;
|
||||||
|
$this->queue_cache_file = $queue_cache_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,12 +50,7 @@ class queue extends \phpbb\cron\task\base
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
if (!class_exists('queue'))
|
$this->queue->process();
|
||||||
{
|
|
||||||
include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
|
|
||||||
}
|
|
||||||
$queue = new \queue();
|
|
||||||
$queue->process();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,7 +62,7 @@ class queue extends \phpbb\cron\task\base
|
||||||
*/
|
*/
|
||||||
public function is_runnable()
|
public function is_runnable()
|
||||||
{
|
{
|
||||||
return file_exists($this->cache_dir . 'queue.' . $this->php_ext);
|
return file_exists($this->queue_cache_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
namespace phpbb\db\migration\data\v310;
|
namespace phpbb\db\migration\data\v310;
|
||||||
|
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
class notification_options_reconvert extends \phpbb\db\migration\migration
|
class notification_options_reconvert extends \phpbb\db\migration\migration
|
||||||
{
|
{
|
||||||
public static function depends_on()
|
public static function depends_on()
|
||||||
|
@ -67,12 +69,12 @@ class notification_options_reconvert extends \phpbb\db\migration\migration
|
||||||
// In-board notification
|
// In-board notification
|
||||||
$notification_methods[] = '';
|
$notification_methods[] = '';
|
||||||
|
|
||||||
if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH)
|
if ($row['user_notify_type'] == messenger_interface::NOTIFY_EMAIL || $row['user_notify_type'] == messenger_interface::NOTIFY_BOTH)
|
||||||
{
|
{
|
||||||
$notification_methods[] = 'email';
|
$notification_methods[] = 'email';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH)
|
if ($row['user_notify_type'] == messenger_interface::NOTIFY_IM || $row['user_notify_type'] == messenger_interface::NOTIFY_BOTH)
|
||||||
{
|
{
|
||||||
$notification_methods[] = 'jabber';
|
$notification_methods[] = 'jabber';
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\db\migration\data\v400;
|
||||||
|
|
||||||
|
use phpbb\db\migration\migration;
|
||||||
|
|
||||||
|
class remove_smtp_auth_method extends migration
|
||||||
|
{
|
||||||
|
public function effectively_installed()
|
||||||
|
{
|
||||||
|
return !$this->config->offsetExists('smtp_auth_method');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function depends_on()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'\phpbb\db\migration\data\v400\dev',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_data()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['config.remove', ['smtp_auth_method']],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function revert_data()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['config.add', ['smtp_auth_method', 'PLAIN']],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -195,7 +195,6 @@ class install extends \phpbb\console\command\command
|
||||||
$iohandler->set_input('smtp_delivery', $config['email']['smtp_delivery']);
|
$iohandler->set_input('smtp_delivery', $config['email']['smtp_delivery']);
|
||||||
$iohandler->set_input('smtp_host', $config['email']['smtp_host']);
|
$iohandler->set_input('smtp_host', $config['email']['smtp_host']);
|
||||||
$iohandler->set_input('smtp_port', $config['email']['smtp_port']);
|
$iohandler->set_input('smtp_port', $config['email']['smtp_port']);
|
||||||
$iohandler->set_input('smtp_auth', $config['email']['smtp_auth']);
|
|
||||||
$iohandler->set_input('smtp_user', $config['email']['smtp_user']);
|
$iohandler->set_input('smtp_user', $config['email']['smtp_user']);
|
||||||
$iohandler->set_input('smtp_pass', $config['email']['smtp_pass']);
|
$iohandler->set_input('smtp_pass', $config['email']['smtp_pass']);
|
||||||
$iohandler->set_input('submit_email', 'submit');
|
$iohandler->set_input('submit_email', 'submit');
|
||||||
|
|
|
@ -97,9 +97,6 @@ class installer_configuration implements ConfigurationInterface
|
||||||
->scalarNode('smtp_port')
|
->scalarNode('smtp_port')
|
||||||
->defaultValue(null)
|
->defaultValue(null)
|
||||||
->end()
|
->end()
|
||||||
->scalarNode('smtp_auth')
|
|
||||||
->defaultValue(null)
|
|
||||||
->end()
|
|
||||||
->scalarNode('smtp_user')
|
->scalarNode('smtp_user')
|
||||||
->defaultValue(null)
|
->defaultValue(null)
|
||||||
->end()
|
->end()
|
||||||
|
|
|
@ -150,7 +150,6 @@ class add_config_settings extends database_task
|
||||||
'smtp_delivery' => $this->install_config->get('smtp_delivery'),
|
'smtp_delivery' => $this->install_config->get('smtp_delivery'),
|
||||||
'smtp_host' => $this->install_config->get('smtp_host'),
|
'smtp_host' => $this->install_config->get('smtp_host'),
|
||||||
'smtp_port' => $this->install_config->get('smtp_port'),
|
'smtp_port' => $this->install_config->get('smtp_port'),
|
||||||
'smtp_auth_method' => $this->install_config->get('smtp_auth'),
|
|
||||||
'smtp_username' => $this->install_config->get('smtp_user'),
|
'smtp_username' => $this->install_config->get('smtp_user'),
|
||||||
'smtp_password' => $this->install_config->get('smtp_pass'),
|
'smtp_password' => $this->install_config->get('smtp_pass'),
|
||||||
|
|
||||||
|
|
|
@ -14,62 +14,52 @@
|
||||||
namespace phpbb\install\module\install_finish\task;
|
namespace phpbb\install\module\install_finish\task;
|
||||||
|
|
||||||
use phpbb\config\db;
|
use phpbb\config\db;
|
||||||
|
use phpbb\install\helper\config;
|
||||||
|
use phpbb\install\helper\iohandler\iohandler_interface;
|
||||||
|
use phpbb\auth\auth;
|
||||||
|
use phpbb\log\log_interface;
|
||||||
|
use phpbb\user;
|
||||||
|
use phpbb\install\helper\container_factory;
|
||||||
|
use phpbb\messenger\method\email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs installation and sends an email to the admin
|
* Logs installation and sends an email to the admin
|
||||||
*/
|
*/
|
||||||
class notify_user extends \phpbb\install\task_base
|
class notify_user extends \phpbb\install\task_base
|
||||||
{
|
{
|
||||||
/**
|
/** @var config */
|
||||||
* @var \phpbb\install\helper\config
|
|
||||||
*/
|
|
||||||
protected $install_config;
|
protected $install_config;
|
||||||
|
|
||||||
/**
|
/** @var iohandler_interface */
|
||||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
|
||||||
*/
|
|
||||||
protected $iohandler;
|
protected $iohandler;
|
||||||
|
|
||||||
/**
|
/** @var auth */
|
||||||
* @var \phpbb\auth\auth
|
|
||||||
*/
|
|
||||||
protected $auth;
|
protected $auth;
|
||||||
|
|
||||||
/**
|
/** @var db */
|
||||||
* @var db
|
|
||||||
*/
|
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
/**
|
/** @var email */
|
||||||
* @var \phpbb\log\log_interface
|
protected $email_method;
|
||||||
*/
|
|
||||||
|
/** @var log_interface */
|
||||||
protected $log;
|
protected $log;
|
||||||
|
|
||||||
/**
|
/** @var string */
|
||||||
* @var \phpbb\user
|
|
||||||
*/
|
|
||||||
protected $user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $phpbb_root_path;
|
protected $phpbb_root_path;
|
||||||
|
|
||||||
/**
|
/** @var user */
|
||||||
* @var string
|
protected $user;
|
||||||
*/
|
|
||||||
protected $php_ext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param \phpbb\install\helper\container_factory $container
|
* @param container_factory $container
|
||||||
* @param \phpbb\install\helper\config $install_config
|
* @param config $install_config
|
||||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler
|
* @param iohandler_interface $iohandler
|
||||||
* @param string $phpbb_root_path
|
* @param string $phpbb_root_path
|
||||||
* @param string $php_ext
|
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\install\helper\config $install_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, $phpbb_root_path, $php_ext)
|
public function __construct(container_factory $container, config $install_config, iohandler_interface $iohandler, $phpbb_root_path)
|
||||||
{
|
{
|
||||||
$this->install_config = $install_config;
|
$this->install_config = $install_config;
|
||||||
$this->iohandler = $iohandler;
|
$this->iohandler = $iohandler;
|
||||||
|
@ -77,8 +67,8 @@ class notify_user extends \phpbb\install\task_base
|
||||||
$this->auth = $container->get('auth');
|
$this->auth = $container->get('auth');
|
||||||
$this->log = $container->get('log');
|
$this->log = $container->get('log');
|
||||||
$this->user = $container->get('user');
|
$this->user = $container->get('user');
|
||||||
|
$this->email_method = $container->get('messenger.method.email');
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->php_ext = $php_ext;
|
|
||||||
|
|
||||||
// We need to reload config for cases when it doesn't have all values
|
// We need to reload config for cases when it doesn't have all values
|
||||||
/** @var \phpbb\cache\driver\driver_interface $cache */
|
/** @var \phpbb\cache\driver\driver_interface $cache */
|
||||||
|
@ -107,17 +97,15 @@ class notify_user extends \phpbb\install\task_base
|
||||||
|
|
||||||
if ($this->config['email_enable'])
|
if ($this->config['email_enable'])
|
||||||
{
|
{
|
||||||
include ($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
|
$this->email_method->set_use_queue(false);
|
||||||
|
$this->email_method->template('installed', $this->install_config->get('user_language', 'en'));
|
||||||
$messenger = new \messenger(false);
|
$this->email_method->to($this->config['board_email'], $this->install_config->get('admin_name'));
|
||||||
$messenger->template('installed', $this->install_config->get('user_language', 'en'));
|
$this->email_method->anti_abuse_headers($this->config, $this->user);
|
||||||
$messenger->to($this->config['board_email'], $this->install_config->get('admin_name'));
|
$this->email_method->assign_vars([
|
||||||
$messenger->anti_abuse_headers($this->config, $this->user);
|
|
||||||
$messenger->assign_vars(array(
|
|
||||||
'USERNAME' => html_entity_decode($this->install_config->get('admin_name'), ENT_COMPAT),
|
'USERNAME' => html_entity_decode($this->install_config->get('admin_name'), ENT_COMPAT),
|
||||||
'PASSWORD' => html_entity_decode($this->install_config->get('admin_passwd'), ENT_COMPAT))
|
'PASSWORD' => html_entity_decode($this->install_config->get('admin_passwd'), ENT_COMPAT),
|
||||||
);
|
]);
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
$this->email_method->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Login admin
|
// Login admin
|
||||||
|
@ -141,7 +129,7 @@ class notify_user extends \phpbb\install\task_base
|
||||||
$this->user->ip,
|
$this->user->ip,
|
||||||
'LOG_INSTALL_INSTALLED',
|
'LOG_INSTALL_INSTALLED',
|
||||||
false,
|
false,
|
||||||
array($this->config['version'])
|
[$this->config['version']]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remove install_lock
|
// Remove install_lock
|
||||||
|
|
|
@ -52,12 +52,9 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||||
$smtp_delivery = $this->io_handler->get_input('smtp_delivery', '');
|
$smtp_delivery = $this->io_handler->get_input('smtp_delivery', '');
|
||||||
$smtp_host = $this->io_handler->get_input('smtp_host', '', true);
|
$smtp_host = $this->io_handler->get_input('smtp_host', '', true);
|
||||||
$smtp_port = $this->io_handler->get_input('smtp_port', '');
|
$smtp_port = $this->io_handler->get_input('smtp_port', '');
|
||||||
$smtp_auth = $this->io_handler->get_input('smtp_auth', '');
|
|
||||||
$smtp_user = $this->io_handler->get_input('smtp_user', '', true);
|
$smtp_user = $this->io_handler->get_input('smtp_user', '', true);
|
||||||
$smtp_passwd = $this->io_handler->get_input('smtp_pass', '', true);
|
$smtp_passwd = $this->io_handler->get_input('smtp_pass', '', true);
|
||||||
|
|
||||||
$auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
|
|
||||||
|
|
||||||
// Check if data is sent
|
// Check if data is sent
|
||||||
if ($this->io_handler->get_input('submit_email', false))
|
if ($this->io_handler->get_input('submit_email', false))
|
||||||
{
|
{
|
||||||
|
@ -65,22 +62,11 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||||
$this->install_config->set('smtp_delivery', $smtp_delivery);
|
$this->install_config->set('smtp_delivery', $smtp_delivery);
|
||||||
$this->install_config->set('smtp_host', $smtp_host);
|
$this->install_config->set('smtp_host', $smtp_host);
|
||||||
$this->install_config->set('smtp_port', $smtp_port);
|
$this->install_config->set('smtp_port', $smtp_port);
|
||||||
$this->install_config->set('smtp_auth', $smtp_auth);
|
|
||||||
$this->install_config->set('smtp_user', $smtp_user);
|
$this->install_config->set('smtp_user', $smtp_user);
|
||||||
$this->install_config->set('smtp_pass', $smtp_passwd);
|
$this->install_config->set('smtp_pass', $smtp_passwd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$auth_options = array();
|
|
||||||
foreach ($auth_methods as $method)
|
|
||||||
{
|
|
||||||
$auth_options[] = array(
|
|
||||||
'value' => $method,
|
|
||||||
'label' => 'SMTP_' . str_replace('-', '_', $method),
|
|
||||||
'selected' => false,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$email_form = array(
|
$email_form = array(
|
||||||
'email_enable' => array(
|
'email_enable' => array(
|
||||||
'label' => 'ENABLE_EMAIL',
|
'label' => 'ENABLE_EMAIL',
|
||||||
|
@ -126,12 +112,6 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => $smtp_port,
|
'default' => $smtp_port,
|
||||||
),
|
),
|
||||||
'smtp_auth' => array(
|
|
||||||
'label' => 'SMTP_AUTH_METHOD',
|
|
||||||
'description' => 'SMTP_AUTH_METHOD_EXPLAIN',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => $auth_options,
|
|
||||||
),
|
|
||||||
'smtp_user' => array(
|
'smtp_user' => array(
|
||||||
'label' => 'SMTP_USERNAME',
|
'label' => 'SMTP_USERNAME',
|
||||||
'description' => 'SMTP_USERNAME_EXPLAIN',
|
'description' => 'SMTP_USERNAME_EXPLAIN',
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
namespace phpbb\message;
|
namespace phpbb\message;
|
||||||
|
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class admin_form
|
* Class admin_form
|
||||||
* Displays a message to the user and allows him to send an email
|
* Displays a message to the user and allows him to send an email
|
||||||
|
@ -85,7 +87,7 @@ class admin_form extends form
|
||||||
/**
|
/**
|
||||||
* {inheritDoc}
|
* {inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function submit(\messenger $messenger)
|
public function submit(\phpbb\di\service_collection $messenger)
|
||||||
{
|
{
|
||||||
if (!$this->subject)
|
if (!$this->subject)
|
||||||
{
|
{
|
||||||
|
@ -155,7 +157,7 @@ class admin_form extends form
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name);
|
$this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name);
|
||||||
$this->message->set_sender_notify_type(NOTIFY_EMAIL);
|
$this->message->set_sender_notify_type(messenger_interface::NOTIFY_EMAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->message->set_template('contact_admin');
|
$this->message->set_template('contact_admin');
|
||||||
|
@ -165,7 +167,7 @@ class admin_form extends form
|
||||||
$this->user->lang['ADMINISTRATOR'],
|
$this->user->lang['ADMINISTRATOR'],
|
||||||
$this->config['board_contact'],
|
$this->config['board_contact'],
|
||||||
$this->config['default_lang'],
|
$this->config['default_lang'],
|
||||||
NOTIFY_EMAIL
|
messenger_interface::NOTIFY_EMAIL
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->message->set_template_vars(array(
|
$this->message->set_template_vars(array(
|
||||||
|
|
|
@ -129,10 +129,10 @@ abstract class form
|
||||||
/**
|
/**
|
||||||
* Submit form, generate the email and send it
|
* Submit form, generate the email and send it
|
||||||
*
|
*
|
||||||
* @param \messenger $messenger
|
* @param \phpbb\di\service_collection $messenger
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function submit(\messenger $messenger)
|
public function submit(\phpbb\di\service_collection $messenger)
|
||||||
{
|
{
|
||||||
if (!check_form_key('memberlist_email'))
|
if (!check_form_key('memberlist_email'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
namespace phpbb\message;
|
namespace phpbb\message;
|
||||||
|
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class message
|
* Class message
|
||||||
* Holds all information for an email and sends it in the end
|
* Holds all information for an email and sends it in the end
|
||||||
|
@ -46,7 +48,7 @@ class message
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $sender_jabber = '';
|
protected $sender_jabber = '';
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $sender_notify_type = NOTIFY_EMAIL;
|
protected $sender_notify_type = messenger_interface::NOTIFY_EMAIL;
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $recipients;
|
protected $recipients;
|
||||||
|
@ -134,14 +136,14 @@ class message
|
||||||
* @param string $recipient_jabber
|
* @param string $recipient_jabber
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '')
|
public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = messenger_interface::NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '')
|
||||||
{
|
{
|
||||||
$this->recipients[] = array(
|
$this->recipients[] = array(
|
||||||
'name' => $recipient_name,
|
'name' => $recipient_name,
|
||||||
'address' => $recipient_address,
|
'user_email' => $recipient_address,
|
||||||
'lang' => $recipient_lang,
|
'lang' => $recipient_lang,
|
||||||
'username' => $recipient_username,
|
'username' => $recipient_username,
|
||||||
'jabber' => $recipient_jabber,
|
'user_jabber' => $recipient_jabber,
|
||||||
'notify_type' => $recipient_notify_type,
|
'notify_type' => $recipient_notify_type,
|
||||||
'to_name' => $recipient_name,
|
'to_name' => $recipient_name,
|
||||||
);
|
);
|
||||||
|
@ -220,10 +222,10 @@ class message
|
||||||
|
|
||||||
$this->recipients[] = array(
|
$this->recipients[] = array(
|
||||||
'lang' => $this->sender_lang,
|
'lang' => $this->sender_lang,
|
||||||
'address' => $this->sender_address,
|
'user_email' => $this->sender_address,
|
||||||
'name' => $this->sender_name,
|
'name' => $this->sender_name,
|
||||||
'username' => $this->sender_username,
|
'username' => $this->sender_username,
|
||||||
'jabber' => $this->sender_jabber,
|
'user_jabber' => $this->sender_jabber,
|
||||||
'notify_type' => $this->sender_notify_type,
|
'notify_type' => $this->sender_notify_type,
|
||||||
'to_name' => $this->recipients[0]['to_name'],
|
'to_name' => $this->recipients[0]['to_name'],
|
||||||
);
|
);
|
||||||
|
@ -232,11 +234,11 @@ class message
|
||||||
/**
|
/**
|
||||||
* Send the email
|
* Send the email
|
||||||
*
|
*
|
||||||
* @param \messenger $messenger
|
* @param \phpbb\di\service_collection $messenger
|
||||||
* @param string $contact
|
* @param string $contact
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function send(\messenger $messenger, $contact)
|
public function send(\phpbb\di\service_collection $messenger, $contact)
|
||||||
{
|
{
|
||||||
if (!count($this->recipients))
|
if (!count($this->recipients))
|
||||||
{
|
{
|
||||||
|
@ -245,38 +247,45 @@ class message
|
||||||
|
|
||||||
foreach ($this->recipients as $recipient)
|
foreach ($this->recipients as $recipient)
|
||||||
{
|
{
|
||||||
$messenger->template($this->template, $recipient['lang']);
|
/** @psalm-suppress InvalidTemplateParam */
|
||||||
$messenger->replyto($this->sender_address);
|
$messenger_collection_iterator = $messenger->getIterator();
|
||||||
$messenger->to($recipient['address'], $recipient['name']);
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
$messenger->im($recipient['jabber'], $recipient['username']);
|
{
|
||||||
|
$messenger_method->set_use_queue(false);
|
||||||
$messenger->headers('X-AntiAbuse: Board servername - ' . $this->server_name);
|
if ($messenger_method->get_id() == $recipient['notify_type'] || $recipient['notify_type'] == $messenger_method::NOTIFY_BOTH)
|
||||||
$messenger->headers('X-AntiAbuse: User IP - ' . $this->sender_ip);
|
{
|
||||||
|
$messenger_method->template($this->template, $recipient['lang']);
|
||||||
|
$messenger_method->set_addresses($recipient);
|
||||||
|
$messenger_method->reply_to($this->sender_address);
|
||||||
|
|
||||||
|
$messenger_method->header('X-AntiAbuse', 'Board servername - ' . $this->server_name);
|
||||||
|
$messenger_method->header('X-AntiAbuse', 'User IP - ' . $this->sender_ip);
|
||||||
if ($this->sender_id)
|
if ($this->sender_id)
|
||||||
{
|
{
|
||||||
$messenger->headers('X-AntiAbuse: User_id - ' . $this->sender_id);
|
$messenger_method->header('X-AntiAbuse', 'User_id - ' . $this->sender_id);
|
||||||
}
|
}
|
||||||
if ($this->sender_username)
|
if ($this->sender_username)
|
||||||
{
|
{
|
||||||
$messenger->headers('X-AntiAbuse: Username - ' . $this->sender_username);
|
$messenger_method->header('X-AntiAbuse', 'Username - ' . $this->sender_username);
|
||||||
}
|
}
|
||||||
|
|
||||||
$messenger->subject(html_entity_decode($this->subject, ENT_COMPAT));
|
$messenger_method->subject(html_entity_decode($this->subject, ENT_COMPAT));
|
||||||
|
|
||||||
$messenger->assign_vars(array(
|
$messenger_method->assign_vars([
|
||||||
'BOARD_CONTACT' => $contact,
|
'BOARD_CONTACT' => $contact,
|
||||||
'TO_USERNAME' => html_entity_decode($recipient['to_name'], ENT_COMPAT),
|
'TO_USERNAME' => html_entity_decode($recipient['to_name'], ENT_COMPAT),
|
||||||
'FROM_USERNAME' => html_entity_decode($this->sender_name, ENT_COMPAT),
|
'FROM_USERNAME' => html_entity_decode($this->sender_name, ENT_COMPAT),
|
||||||
'MESSAGE' => html_entity_decode($this->body, ENT_COMPAT))
|
'MESSAGE' => html_entity_decode($this->body, ENT_COMPAT),
|
||||||
);
|
]);
|
||||||
|
|
||||||
if (count($this->template_vars))
|
if (count($this->template_vars))
|
||||||
{
|
{
|
||||||
$messenger->assign_vars($this->template_vars);
|
$messenger_method->assign_vars($this->template_vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
$messenger->send($recipient['notify_type']);
|
$messenger_method->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
namespace phpbb\message;
|
namespace phpbb\message;
|
||||||
|
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class topic_form
|
* Class topic_form
|
||||||
* Form used to send topics as notification emails
|
* Form used to send topics as notification emails
|
||||||
|
@ -108,7 +110,7 @@ class topic_form extends form
|
||||||
/**
|
/**
|
||||||
* {inheritDoc}
|
* {inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function submit(\messenger $messenger)
|
public function submit(\phpbb\di\service_collection $messenger)
|
||||||
{
|
{
|
||||||
if (!$this->recipient_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->recipient_address))
|
if (!$this->recipient_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->recipient_address))
|
||||||
{
|
{
|
||||||
|
@ -130,9 +132,9 @@ class topic_form extends form
|
||||||
$this->recipient_name,
|
$this->recipient_name,
|
||||||
$this->recipient_address,
|
$this->recipient_address,
|
||||||
$this->recipient_lang,
|
$this->recipient_lang,
|
||||||
NOTIFY_EMAIL
|
messenger_interface::NOTIFY_EMAIL
|
||||||
);
|
);
|
||||||
$this->message->set_sender_notify_type(NOTIFY_EMAIL);
|
$this->message->set_sender_notify_type(messenger_interface::NOTIFY_EMAIL);
|
||||||
|
|
||||||
parent::submit($messenger);
|
parent::submit($messenger);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ class user_form extends form
|
||||||
/**
|
/**
|
||||||
* {inheritDoc}
|
* {inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function submit(\messenger $messenger)
|
public function submit(\phpbb\di\service_collection $messenger)
|
||||||
{
|
{
|
||||||
if (!$this->subject)
|
if (!$this->subject)
|
||||||
{
|
{
|
||||||
|
|
484
phpBB/phpbb/messenger/method/base.php
Normal file
484
phpBB/phpbb/messenger/method/base.php
Normal file
|
@ -0,0 +1,484 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\messenger\method;
|
||||||
|
|
||||||
|
use phpbb\config\config;
|
||||||
|
use phpbb\di\service_collection;
|
||||||
|
use phpbb\event\dispatcher;
|
||||||
|
use phpbb\extension\manager;
|
||||||
|
use phpbb\language\language;
|
||||||
|
use phpbb\log\log_interface;
|
||||||
|
use phpbb\path_helper;
|
||||||
|
use phpbb\request\request;
|
||||||
|
use phpbb\messenger\queue;
|
||||||
|
use phpbb\template\assets_bag;
|
||||||
|
use phpbb\template\twig\lexer;
|
||||||
|
use phpbb\user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Messenger base class
|
||||||
|
*/
|
||||||
|
abstract class base implements messenger_interface
|
||||||
|
{
|
||||||
|
/** @var array */
|
||||||
|
protected $additional_headers = [];
|
||||||
|
|
||||||
|
/** @var assets_bag */
|
||||||
|
protected $assets_bag;
|
||||||
|
|
||||||
|
/** @var config */
|
||||||
|
protected $config;
|
||||||
|
|
||||||
|
/** @var dispatcher */
|
||||||
|
protected $dispatcher;
|
||||||
|
|
||||||
|
/** @var manager */
|
||||||
|
protected $ext_manager;
|
||||||
|
|
||||||
|
/** @var language */
|
||||||
|
protected $language;
|
||||||
|
|
||||||
|
/** @var log_interface */
|
||||||
|
protected $log;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $msg = '';
|
||||||
|
|
||||||
|
/** @var queue */
|
||||||
|
protected $queue;
|
||||||
|
|
||||||
|
/** @var path_helper */
|
||||||
|
protected $path_helper;
|
||||||
|
|
||||||
|
/** @var request */
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $root_path;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $subject = '';
|
||||||
|
|
||||||
|
/** @var \phpbb\template\template */
|
||||||
|
protected $template;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $template_cache_path;
|
||||||
|
|
||||||
|
/** @var service_collection */
|
||||||
|
protected $twig_extensions_collection;
|
||||||
|
|
||||||
|
/** @var lexer */
|
||||||
|
protected $twig_lexer;
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
protected $use_queue = true;
|
||||||
|
|
||||||
|
/** @var user */
|
||||||
|
protected $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Messenger base class constructor
|
||||||
|
*
|
||||||
|
* @param assets_bag $assets_bag
|
||||||
|
* @param config $config
|
||||||
|
* @param dispatcher $dispatcher
|
||||||
|
* @param language $language
|
||||||
|
* @param queue $queue
|
||||||
|
* @param path_helper $path_helper
|
||||||
|
* @param request $request
|
||||||
|
* @param service_collection $twig_extensions_collection
|
||||||
|
* @param lexer $twig_lexer
|
||||||
|
* @param user $user
|
||||||
|
* @param string $phpbb_root_path
|
||||||
|
* @param string $template_cache_path
|
||||||
|
* @param manager $ext_manager
|
||||||
|
* @param log_interface $log
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
assets_bag $assets_bag,
|
||||||
|
config $config,
|
||||||
|
dispatcher $dispatcher,
|
||||||
|
language $language,
|
||||||
|
queue $queue,
|
||||||
|
path_helper $path_helper,
|
||||||
|
request $request,
|
||||||
|
service_collection $twig_extensions_collection,
|
||||||
|
lexer $twig_lexer,
|
||||||
|
user $user,
|
||||||
|
string $phpbb_root_path,
|
||||||
|
string $template_cache_path,
|
||||||
|
?manager $ext_manager = null,
|
||||||
|
?log_interface $log = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->assets_bag = $assets_bag;
|
||||||
|
$this->config = $config;
|
||||||
|
$this->dispatcher = $dispatcher;
|
||||||
|
$this->ext_manager = $ext_manager;
|
||||||
|
$this->language = $language;
|
||||||
|
$this->log = $log;
|
||||||
|
$this->queue = $queue;
|
||||||
|
$this->path_helper = $path_helper;
|
||||||
|
$this->request = $request;
|
||||||
|
$this->twig_extensions_collection = $twig_extensions_collection;
|
||||||
|
$this->twig_lexer = $twig_lexer;
|
||||||
|
$this->user = $user;
|
||||||
|
$this->root_path = $phpbb_root_path;
|
||||||
|
$this->template_cache_path = $template_cache_path;
|
||||||
|
|
||||||
|
$this->set_use_queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
abstract public function get_id(): int;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
abstract public function is_enabled(): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the use of messenger queue flag
|
||||||
|
*
|
||||||
|
* @param bool $use_queue Flag indicating if cached queue to be used
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function set_use_queue(bool $use_queue = true): void
|
||||||
|
{
|
||||||
|
$this->use_queue = $use_queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all the data (address, template file, etc) or resets to default
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
abstract public function init(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set addresses for to/im as available
|
||||||
|
*
|
||||||
|
* @param array $user_row User row
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
abstract public function set_addresses(array $user_row): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get messenger method fie queue object name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function get_queue_object_name(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function subject(string $subject = ''): void
|
||||||
|
{
|
||||||
|
$this->subject = $subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
abstract public function send(): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send messages from the queue
|
||||||
|
*
|
||||||
|
* @param array $queue_data Queue data array
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
abstract public function process_queue(array &$queue_data): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set email template to use
|
||||||
|
*
|
||||||
|
* @param string $template_file Email template file name
|
||||||
|
* @param string $template_lang Email template language
|
||||||
|
* @param string $template_path Email template path
|
||||||
|
* @param string $template_dir_prefix Email template directory prefix
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function template(string $template_file, string $template_lang = '', string $template_path = '', string $template_dir_prefix = ''): bool
|
||||||
|
{
|
||||||
|
$template_dir_prefix = (!$template_dir_prefix || $template_dir_prefix[0] === '/') ? $template_dir_prefix : '/' . $template_dir_prefix;
|
||||||
|
|
||||||
|
$this->setup_template();
|
||||||
|
|
||||||
|
if (!trim($template_lang))
|
||||||
|
{
|
||||||
|
// fall back to board default language if the user's language is
|
||||||
|
// missing $template_file. If this does not exist either,
|
||||||
|
// $this->template->set_filenames will do a trigger_error
|
||||||
|
$template_lang = basename($this->config['default_lang']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ext_template_paths = [
|
||||||
|
[
|
||||||
|
'name' => $template_lang . '_email',
|
||||||
|
'ext_path' => 'language/' . $template_lang . '/email' . $template_dir_prefix,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($template_path)
|
||||||
|
{
|
||||||
|
$template_paths = [
|
||||||
|
$template_path . $template_dir_prefix,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$template_path = (!empty($this->user->lang_path)) ? $this->user->lang_path : $this->root_path . 'language/';
|
||||||
|
$template_path .= $template_lang . '/email';
|
||||||
|
|
||||||
|
$template_paths = [
|
||||||
|
$template_path . $template_dir_prefix,
|
||||||
|
];
|
||||||
|
|
||||||
|
$board_language = basename($this->config['default_lang']);
|
||||||
|
|
||||||
|
// we can only specify default language fallback when the path is not a custom one for which we
|
||||||
|
// do not know the default language alternative
|
||||||
|
if ($template_lang !== $board_language)
|
||||||
|
{
|
||||||
|
$fallback_template_path = (!empty($this->user->lang_path)) ? $this->user->lang_path : $this->root_path . 'language/';
|
||||||
|
$fallback_template_path .= $board_language . '/email';
|
||||||
|
|
||||||
|
$template_paths[] = $fallback_template_path . $template_dir_prefix;
|
||||||
|
|
||||||
|
$ext_template_paths[] = [
|
||||||
|
'name' => $board_language . '_email',
|
||||||
|
'ext_path' => 'language/' . $board_language . '/email' . $template_dir_prefix,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
// If everything fails just fall back to en template
|
||||||
|
if ($template_lang !== 'en' && $board_language !== 'en')
|
||||||
|
{
|
||||||
|
$fallback_template_path = (!empty($this->user->lang_path)) ? $this->user->lang_path : $this->root_path . 'language/';
|
||||||
|
$fallback_template_path .= 'en/email';
|
||||||
|
|
||||||
|
$template_paths[] = $fallback_template_path . $template_dir_prefix;
|
||||||
|
|
||||||
|
$ext_template_paths[] = [
|
||||||
|
'name' => 'en_email',
|
||||||
|
'ext_path' => 'language/en/email' . $template_dir_prefix,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->set_template_paths($ext_template_paths, $template_paths);
|
||||||
|
|
||||||
|
$this->template->set_filenames([
|
||||||
|
'body' => $template_file . '.txt',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign variables to email template
|
||||||
|
*
|
||||||
|
* @param array $vars Array of VAR => VALUE to assign to email template
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function assign_vars(array $vars): void
|
||||||
|
{
|
||||||
|
$this->setup_template();
|
||||||
|
$this->template->assign_vars($vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign block of variables to email template
|
||||||
|
*
|
||||||
|
* @param string $blockname Template block name
|
||||||
|
* @param array $vars Array of VAR => VALUE to assign to email template block
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function assign_block_vars(string $blockname, array $vars): void
|
||||||
|
{
|
||||||
|
$this->setup_template();
|
||||||
|
|
||||||
|
$this->template->assign_block_vars($blockname, $vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare message before sending out to the recipients
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function prepare_message(): void
|
||||||
|
{
|
||||||
|
// We add some standard variables we always use, no need to specify them always
|
||||||
|
$this->assign_vars([
|
||||||
|
'U_BOARD' => generate_board_url(),
|
||||||
|
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . html_entity_decode($this->config['board_email_sig'], ENT_COMPAT)),
|
||||||
|
'SITENAME' => html_entity_decode($this->config['sitename'], ENT_COMPAT),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$subject = $this->subject;
|
||||||
|
$template = $this->template;
|
||||||
|
/**
|
||||||
|
* Event to modify the template before parsing
|
||||||
|
*
|
||||||
|
* @event core.modify_notification_template
|
||||||
|
* @var string subject The message subject
|
||||||
|
* @var string template The (readonly) template object
|
||||||
|
* @since 3.2.4-RC1
|
||||||
|
* @changed 4.0.0-a1 Removed vars: method, break.
|
||||||
|
*/
|
||||||
|
$vars = ['subject', 'template'];
|
||||||
|
extract($this->dispatcher->trigger_event('core.modify_notification_template', compact($vars)));
|
||||||
|
|
||||||
|
// Parse message through template
|
||||||
|
$message = trim($this->template->assign_display('body'));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event to modify notification message text after parsing
|
||||||
|
*
|
||||||
|
* @event core.modify_notification_message
|
||||||
|
* @var string message The message text
|
||||||
|
* @var string subject The message subject
|
||||||
|
* @since 3.1.11-RC1
|
||||||
|
* @changed 4.0.0-a1 Removed vars: method, break.
|
||||||
|
*/
|
||||||
|
$vars = ['message', 'subject'];
|
||||||
|
extract($this->dispatcher->trigger_event('core.modify_notification_message', compact($vars)));
|
||||||
|
|
||||||
|
$this->subject = $subject;
|
||||||
|
$this->msg = $message;
|
||||||
|
unset($subject, $message, $template);
|
||||||
|
|
||||||
|
// Because we use \n for newlines in the body message we need to fix line encoding errors for those admins who uploaded email template files in the wrong encoding
|
||||||
|
$this->msg = str_replace("\r\n", "\n", $this->msg);
|
||||||
|
|
||||||
|
// We now try and pull a subject from the email body ... if it exists,
|
||||||
|
// do this here because the subject may contain a variable
|
||||||
|
$drop_header = '';
|
||||||
|
$match = [];
|
||||||
|
if (preg_match('#^(Subject):(.*?)$#m', $this->msg, $match))
|
||||||
|
{
|
||||||
|
$this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : $this->language->lang('NO_EMAIL_SUBJECT'));
|
||||||
|
$drop_header .= '[\r\n]*?' . preg_quote($match[0], '#');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->subject = (($this->subject != '') ? $this->subject : $this->language->lang('NO_EMAIL_SUBJECT'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('#^(List-Unsubscribe):(.*?)$#m', $this->msg, $match))
|
||||||
|
{
|
||||||
|
$drop_header .= '[\r\n]*?' . preg_quote($match[0], '#');
|
||||||
|
$this->additional_headers[$match[1]] = trim($match[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($drop_header)
|
||||||
|
{
|
||||||
|
$this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function error(string $msg): void
|
||||||
|
{
|
||||||
|
// Session doesn't exist, create it
|
||||||
|
if (!isset($this->user->session_id) || $this->user->session_id === '')
|
||||||
|
{
|
||||||
|
$this->user->session_begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = strtoupper($this->get_queue_object_name());
|
||||||
|
$calling_page = html_entity_decode($this->request->server('PHP_SELF'), ENT_COMPAT);
|
||||||
|
$message = '<strong>' . $type . '</strong><br><em>' . htmlspecialchars($calling_page, ENT_COMPAT) . '</em><br><br>' . $msg . '<br>';
|
||||||
|
if ($this->log)
|
||||||
|
{
|
||||||
|
$this->log->add('critical', $this->user->data['user_id'], $this->user->ip, 'LOG_ERROR_' . $type, false, [$message]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save message data to the messenger file queue
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function save_queue(): void
|
||||||
|
{
|
||||||
|
if ($this->use_queue && !empty($this->queue))
|
||||||
|
{
|
||||||
|
$this->queue->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup template engine
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function setup_template(): void
|
||||||
|
{
|
||||||
|
if (isset($this->template) && $this->template instanceof \phpbb\template\template)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template_environment = new \phpbb\template\twig\environment(
|
||||||
|
$this->assets_bag,
|
||||||
|
$this->config,
|
||||||
|
new \phpbb\filesystem\filesystem(),
|
||||||
|
$this->path_helper,
|
||||||
|
$this->template_cache_path,
|
||||||
|
$this->ext_manager,
|
||||||
|
new \phpbb\template\twig\loader(),
|
||||||
|
$this->dispatcher,
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
$template_environment->setLexer($this->twig_lexer);
|
||||||
|
|
||||||
|
$this->template = new \phpbb\template\twig\twig(
|
||||||
|
$this->path_helper,
|
||||||
|
$this->config,
|
||||||
|
new \phpbb\template\context(),
|
||||||
|
$template_environment,
|
||||||
|
$this->template_cache_path,
|
||||||
|
$this->user,
|
||||||
|
$this->twig_extensions_collection,
|
||||||
|
$this->ext_manager
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set template paths to load
|
||||||
|
*
|
||||||
|
* @param string|array $path_name Email template path name
|
||||||
|
* @param string|array $paths Email template paths
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function set_template_paths(string|array $path_name, string|array $paths): void
|
||||||
|
{
|
||||||
|
$this->setup_template();
|
||||||
|
$this->template->set_custom_style($path_name, $paths);
|
||||||
|
}
|
||||||
|
}
|
579
phpBB/phpbb/messenger/method/email.php
Normal file
579
phpBB/phpbb/messenger/method/email.php
Normal file
|
@ -0,0 +1,579 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\messenger\method;
|
||||||
|
|
||||||
|
use Symfony\Component\Mailer\Transport;
|
||||||
|
use Symfony\Component\Mailer\Mailer;
|
||||||
|
use Symfony\Component\Mime\Address;
|
||||||
|
use Symfony\Component\Mime\Email as symfony_email;
|
||||||
|
use Symfony\Component\Mime\Header\Headers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Messenger class
|
||||||
|
*/
|
||||||
|
class email extends base
|
||||||
|
{
|
||||||
|
/** @var array */
|
||||||
|
private const PRIORITY_MAP = [
|
||||||
|
symfony_email::PRIORITY_HIGHEST => 'Highest',
|
||||||
|
symfony_email::PRIORITY_HIGH => 'High',
|
||||||
|
symfony_email::PRIORITY_NORMAL => 'Normal',
|
||||||
|
symfony_email::PRIORITY_LOW => 'Low',
|
||||||
|
symfony_email::PRIORITY_LOWEST => 'Lowest',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* Symfony Mailer transport DSN
|
||||||
|
*/
|
||||||
|
protected $dsn = '';
|
||||||
|
|
||||||
|
/** @var symfony_email */
|
||||||
|
protected $email;
|
||||||
|
|
||||||
|
/** @var Address */
|
||||||
|
protected $from;
|
||||||
|
|
||||||
|
/** @var Headers */
|
||||||
|
protected $headers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*
|
||||||
|
* Possible values are:
|
||||||
|
* symfony_email::PRIORITY_HIGHEST
|
||||||
|
* symfony_email::PRIORITY_HIGH
|
||||||
|
* symfony_email::PRIORITY_NORMAL
|
||||||
|
* symfony_email::PRIORITY_LOW
|
||||||
|
* symfony_email::PRIORITY_LOWEST
|
||||||
|
*/
|
||||||
|
protected $mail_priority = symfony_email::PRIORITY_NORMAL;
|
||||||
|
|
||||||
|
/** @var \phpbb\messenger\queue */
|
||||||
|
protected $queue;
|
||||||
|
|
||||||
|
/** @var Address */
|
||||||
|
protected $reply_to;
|
||||||
|
|
||||||
|
/** @var \Symfony\Component\Mailer\Transport\AbstractTransport */
|
||||||
|
protected $transport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_id(): int
|
||||||
|
{
|
||||||
|
return self::NOTIFY_EMAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_queue_object_name(): string
|
||||||
|
{
|
||||||
|
return 'email';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function is_enabled(): bool
|
||||||
|
{
|
||||||
|
return (bool) $this->config['email_enable'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function init(): void
|
||||||
|
{
|
||||||
|
$this->email = new symfony_email();
|
||||||
|
$this->headers = $this->email->getHeaders();
|
||||||
|
$this->subject = $this->msg = '';
|
||||||
|
$this->mail_priority = symfony_email::PRIORITY_NORMAL;
|
||||||
|
|
||||||
|
$this->additional_headers = [];
|
||||||
|
$this->use_queue = true;
|
||||||
|
unset($this->template, $this->reply_to, $this->from);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function set_use_queue(bool $use_queue = true): void
|
||||||
|
{
|
||||||
|
$this->use_queue = !$this->config['email_package_size'] ? false : $use_queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function set_addresses(array $user_row): void
|
||||||
|
{
|
||||||
|
if (!empty($user_row['user_email']))
|
||||||
|
{
|
||||||
|
$this->to($user_row['user_email'], $user_row['username'] ?: '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets email address to send to
|
||||||
|
*
|
||||||
|
* @param string $address Email "To" recipient address
|
||||||
|
* @param string $realname Email "To" recipient name
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function to(string $address, string $realname = ''): void
|
||||||
|
{
|
||||||
|
if (!$address = trim($address))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If empty sendmail_path on windows, PHP changes the to line
|
||||||
|
$windows_empty_sendmail_path = !$this->config['smtp_delivery'] && DIRECTORY_SEPARATOR == '\\';
|
||||||
|
|
||||||
|
$to = new Address($address, $windows_empty_sendmail_path ? '' : trim($realname));
|
||||||
|
$this->email->getTo() ? $this->email->addTo($to) : $this->email->to($to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets cc address to send to
|
||||||
|
*
|
||||||
|
* @param string $address Email carbon copy recipient address
|
||||||
|
* @param string $realname Email carbon copy recipient name
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function cc(string $address, string $realname = ''): void
|
||||||
|
{
|
||||||
|
if (!$address = trim($address))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cc = new Address($address, trim($realname));
|
||||||
|
$this->email->getCc() ? $this->email->addCc($cc) : $this->email->cc($cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets bcc address to send to
|
||||||
|
*
|
||||||
|
* @param string $address Email black carbon copy recipient address
|
||||||
|
* @param string $realname Email black carbon copy recipient name
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function bcc(string $address, string $realname = ''): void
|
||||||
|
{
|
||||||
|
if (!$address = trim($address))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$bcc = new Address($address, trim($realname));
|
||||||
|
$this->email->getBcc() ? $this->email->addBcc($bcc) : $this->email->bcc($bcc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the reply to address
|
||||||
|
*
|
||||||
|
* @param string $address Email "Reply to" address
|
||||||
|
* @param string $realname Email "Reply to" recipient name
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function reply_to(string $address, string $realname = ''): void
|
||||||
|
{
|
||||||
|
if (!$address = trim($address))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->reply_to = new Address($address, trim($realname));
|
||||||
|
$this->email->getReplyTo() ? $this->email->addReplyTo($this->reply_to) : $this->email->replyTo($this->reply_to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the from address
|
||||||
|
*
|
||||||
|
* @param string $address Email "from" address
|
||||||
|
* @param string $realname Email "from" recipient name
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function from(string $address, string $realname = ''): void
|
||||||
|
{
|
||||||
|
if (!$address = trim($address))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->from = new Address($address, trim($realname));
|
||||||
|
$this->email->getFrom() ? $this->email->addFrom($this->from) : $this->email->from($this->from);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up subject for mail
|
||||||
|
*
|
||||||
|
* @param string $subject Email subject
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function subject(string $subject = ''): void
|
||||||
|
{
|
||||||
|
parent::subject(trim($subject));
|
||||||
|
$this->email->subject($this->subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds X-AntiAbuse headers
|
||||||
|
*
|
||||||
|
* @param \phpbb\config\config $config Config object
|
||||||
|
* @param \phpbb\user $user User object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function anti_abuse_headers(\phpbb\config\config $config, \phpbb\user $user): void
|
||||||
|
{
|
||||||
|
$this->headers->addHeader('X-AntiAbuse', 'Board servername - ' . $config['server_name']);
|
||||||
|
$this->headers->addHeader('X-AntiAbuse', 'User_id - ' . $user->data['user_id']);
|
||||||
|
$this->headers->addHeader('X-AntiAbuse', 'Username - ' . $user->data['username']);
|
||||||
|
$this->headers->addHeader('X-AntiAbuse', 'User IP - ' . $user->ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the email priority
|
||||||
|
*
|
||||||
|
* Possible values are:
|
||||||
|
* symfony_email::PRIORITY_HIGHEST = 1
|
||||||
|
* symfony_email::PRIORITY_HIGH = 2
|
||||||
|
* symfony_email::PRIORITY_NORMAL = 3
|
||||||
|
* symfony_email::PRIORITY_LOW = 4
|
||||||
|
* symfony_email::PRIORITY_LOWEST = 5
|
||||||
|
*
|
||||||
|
* @param int $priority Email priority level
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function set_mail_priority(int $priority = symfony_email::PRIORITY_NORMAL): void
|
||||||
|
{
|
||||||
|
$this->email->priority($priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set email headers
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function build_headers(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$board_contact = trim($this->config['board_contact']);
|
||||||
|
$contact_name = html_entity_decode($this->config['board_contact_name'], ENT_COMPAT);
|
||||||
|
|
||||||
|
if (empty($this->email->getReplyTo()))
|
||||||
|
{
|
||||||
|
$this->reply_to($board_contact, $contact_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($this->email->getFrom()))
|
||||||
|
{
|
||||||
|
$this->from($board_contact, $contact_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->email->priority($this->mail_priority);
|
||||||
|
|
||||||
|
$headers = [
|
||||||
|
'Return-Path' => new Address($this->config['board_email']),
|
||||||
|
'Sender' => new Address($this->config['board_email']),
|
||||||
|
'X-MSMail-Priority' => self::PRIORITY_MAP[$this->mail_priority],
|
||||||
|
'X-Mailer' => 'phpBB',
|
||||||
|
'X-MimeOLE' => 'phpBB',
|
||||||
|
'X-phpBB-Origin' => 'phpbb://' . str_replace(['http://', 'https://'], ['', ''], generate_board_url()),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Add additional headers
|
||||||
|
$headers = array_merge($headers, $this->additional_headers);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event to modify email header entries
|
||||||
|
*
|
||||||
|
* @event core.modify_email_headers
|
||||||
|
* @var array headers Array containing email header entries
|
||||||
|
* @since 3.1.11-RC1
|
||||||
|
*/
|
||||||
|
$vars = ['headers'];
|
||||||
|
extract($this->dispatcher->trigger_event('core.modify_email_headers', compact($vars)));
|
||||||
|
|
||||||
|
foreach ($headers as $header => $value)
|
||||||
|
{
|
||||||
|
$this->headers->addHeader($header, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates valid DSN for Symfony Mailer transport
|
||||||
|
*
|
||||||
|
* @param string $dsn Symfony Mailer transport DSN
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function set_dsn(string $dsn = ''): void
|
||||||
|
{
|
||||||
|
if (!empty($dsn))
|
||||||
|
{
|
||||||
|
$this->dsn = $dsn;
|
||||||
|
}
|
||||||
|
else if ($this->config['smtp_delivery'])
|
||||||
|
{
|
||||||
|
if (empty($this->config['smtp_host']))
|
||||||
|
{
|
||||||
|
$this->dsn = 'null://null';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$user = urlencode($this->config['smtp_username']);
|
||||||
|
$password = urlencode($this->config['smtp_password']);
|
||||||
|
$smtp_host = urlencode($this->config['smtp_host']);
|
||||||
|
$smtp_port = $this->config['smtp_port'];
|
||||||
|
|
||||||
|
$this->dsn = "smtp://$user:$password@$smtp_host:$smtp_port";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->dsn = 'sendmail://default';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Symfony Mailer transport DSN
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_dsn(): string
|
||||||
|
{
|
||||||
|
return $this->dsn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a valid transport to send email
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function set_transport(): void
|
||||||
|
{
|
||||||
|
if (empty($this->dsn))
|
||||||
|
{
|
||||||
|
$this->set_dsn();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->transport = Transport::fromDsn($this->dsn);
|
||||||
|
|
||||||
|
if ($this->config['smtp_delivery'] && method_exists($this->transport, 'getStream'))
|
||||||
|
{
|
||||||
|
// Set ssl context options, see http://php.net/manual/en/context.ssl.php
|
||||||
|
$options['ssl'] = [
|
||||||
|
'verify_peer' => (bool) $this->config['smtp_verify_peer'],
|
||||||
|
'verify_peer_name' => (bool) $this->config['smtp_verify_peer_name'],
|
||||||
|
'allow_self_signed' => (bool) $this->config['smtp_allow_self_signed'],
|
||||||
|
];
|
||||||
|
$this->transport->getStream()->setStreamOptions($options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function process_queue(array &$queue_data): void
|
||||||
|
{
|
||||||
|
$queue_object_name = $this->get_queue_object_name();
|
||||||
|
$messages_count = count($queue_data[$queue_object_name]['data']);
|
||||||
|
|
||||||
|
if (!$this->is_enabled() || !$messages_count)
|
||||||
|
{
|
||||||
|
unset($queue_data[$queue_object_name]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@set_time_limit(0);
|
||||||
|
|
||||||
|
$package_size = $queue_data[$queue_object_name]['package_size'] ?? 0;
|
||||||
|
$num_items = (!$package_size || $messages_count < $package_size) ? $messages_count : $package_size;
|
||||||
|
$mailer = new Mailer($this->transport);
|
||||||
|
|
||||||
|
for ($i = 0; $i < $num_items; $i++)
|
||||||
|
{
|
||||||
|
// Make variables available...
|
||||||
|
extract(array_shift($queue_data[$queue_object_name]['data']));
|
||||||
|
|
||||||
|
$break = false;
|
||||||
|
/**
|
||||||
|
* Event to send message via external transport
|
||||||
|
*
|
||||||
|
* @event core.notification_message_process
|
||||||
|
* @var string break Flag indicating if the function return after hook
|
||||||
|
* @var string email The Symfony Email object
|
||||||
|
* @since 3.2.4-RC1
|
||||||
|
* @changed 4.0.0-a1 Added vars: email. Removed vars: addresses, subject, msg.
|
||||||
|
*/
|
||||||
|
$vars = [
|
||||||
|
'break',
|
||||||
|
'email',
|
||||||
|
];
|
||||||
|
extract($this->dispatcher->trigger_event('core.notification_message_process', compact($vars)));
|
||||||
|
|
||||||
|
if (!$break)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$mailer->send($email);
|
||||||
|
}
|
||||||
|
catch (\Symfony\Component\Mailer\Exception\TransportExceptionInterface $e)
|
||||||
|
{
|
||||||
|
$this->error($e->getDebug());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No more data for this object? Unset it
|
||||||
|
if (!count($queue_data[$queue_object_name]['data']))
|
||||||
|
{
|
||||||
|
unset($queue_data[$queue_object_name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get mailer transport object
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\Mailer\Transport\TransportInterface Symfony Mailer transport object
|
||||||
|
*/
|
||||||
|
public function get_transport(): \Symfony\Component\Mailer\Transport\TransportInterface
|
||||||
|
{
|
||||||
|
return $this->transport;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function send(): bool
|
||||||
|
{
|
||||||
|
$this->prepare_message();
|
||||||
|
|
||||||
|
$this->email->subject($this->subject);
|
||||||
|
$this->email->text($this->msg);
|
||||||
|
|
||||||
|
$break = false;
|
||||||
|
$subject = $this->subject;
|
||||||
|
$msg = $this->msg;
|
||||||
|
$email = $this->email;
|
||||||
|
/**
|
||||||
|
* Event to send message via external transport
|
||||||
|
*
|
||||||
|
* @event core.notification_message_email
|
||||||
|
* @var bool break Flag indicating if the function return after hook
|
||||||
|
* @var string subject The message subject
|
||||||
|
* @var string msg The message text
|
||||||
|
* @var string email The Symfony Email object
|
||||||
|
* @since 3.2.4-RC1
|
||||||
|
* @changed 4.0.0-a1 Added vars: email. Removed vars: addresses
|
||||||
|
*/
|
||||||
|
$vars = [
|
||||||
|
'break',
|
||||||
|
'subject',
|
||||||
|
'msg',
|
||||||
|
'email',
|
||||||
|
];
|
||||||
|
extract($this->dispatcher->trigger_event('core.notification_message_email', compact($vars)));
|
||||||
|
$this->email = $email;
|
||||||
|
|
||||||
|
$this->build_headers();
|
||||||
|
|
||||||
|
if ($break)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send message ...
|
||||||
|
if (!$this->use_queue)
|
||||||
|
{
|
||||||
|
$mailer = new Mailer($this->transport);
|
||||||
|
|
||||||
|
$subject = $this->subject;
|
||||||
|
$msg = $this->msg;
|
||||||
|
$headers = $this->headers;
|
||||||
|
$email = $this->email;
|
||||||
|
/**
|
||||||
|
* Modify data before sending out emails with PHP's mail function
|
||||||
|
*
|
||||||
|
* @event core.phpbb_mail_before
|
||||||
|
* @var string email The Symfony Email object
|
||||||
|
* @var string subject The message subject
|
||||||
|
* @var string msg The message text
|
||||||
|
* @var string headers The email headers
|
||||||
|
* @since 3.3.6-RC1
|
||||||
|
* @changed 4.0.0-a1 Added vars: email. Removed vars: to, eol, additional_parameters.
|
||||||
|
*/
|
||||||
|
$vars = [
|
||||||
|
'email',
|
||||||
|
'subject',
|
||||||
|
'msg',
|
||||||
|
'headers',
|
||||||
|
];
|
||||||
|
extract($this->dispatcher->trigger_event('core.phpbb_mail_before', compact($vars)));
|
||||||
|
|
||||||
|
$this->subject = $subject;
|
||||||
|
$this->msg = $msg;
|
||||||
|
$this->headers = $headers;
|
||||||
|
$this->email = $email;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$mailer->send($this->email);
|
||||||
|
}
|
||||||
|
catch (\Symfony\Component\Mailer\Exception\TransportExceptionInterface $e)
|
||||||
|
{
|
||||||
|
$this->error($e->getDebug());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute code after sending out emails with PHP's mail function
|
||||||
|
*
|
||||||
|
* @event core.phpbb_mail_after
|
||||||
|
* @var string email The Symfony Email object
|
||||||
|
* @var string subject The message subject
|
||||||
|
* @var string msg The message text
|
||||||
|
* @var string headers The email headers
|
||||||
|
* @since 3.3.6-RC1
|
||||||
|
* @changed 4.0.0-a1 Added vars: email. Removed vars: to, eol, additional_parameters, $result.
|
||||||
|
*/
|
||||||
|
$vars = [
|
||||||
|
'email',
|
||||||
|
'subject',
|
||||||
|
'msg',
|
||||||
|
'headers',
|
||||||
|
];
|
||||||
|
extract($this->dispatcher->trigger_event('core.phpbb_mail_after', compact($vars)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->queue->init('email', $this->config['email_package_size']);
|
||||||
|
$this->queue->put('email', [
|
||||||
|
'email' => $this->email,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset the object
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,95 +1,197 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\messenger\method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
*
|
||||||
*/
|
* Based on Jabber class from Flyspray project
|
||||||
if (!defined('IN_PHPBB'))
|
*
|
||||||
|
* @version class.jabber2.php 1595 2008-09-19 (0.9.9)
|
||||||
|
* @copyright 2006 Flyspray.org
|
||||||
|
* @author Florian Schmitz (floele)
|
||||||
|
*
|
||||||
|
* Slightly modified by Acyd Burn (2006)
|
||||||
|
* Refactored to a service (2024)
|
||||||
|
*/
|
||||||
|
class jabber extends base
|
||||||
{
|
{
|
||||||
exit;
|
/** @var string */
|
||||||
}
|
protected $connect_server;
|
||||||
|
|
||||||
/**
|
/** @var resource|null */
|
||||||
*
|
protected $connection = null;
|
||||||
* Jabber class from Flyspray project
|
|
||||||
*
|
|
||||||
* @version class.jabber2.php 1595 2008-09-19 (0.9.9)
|
|
||||||
* @copyright 2006 Flyspray.org
|
|
||||||
* @author Florian Schmitz (floele)
|
|
||||||
*
|
|
||||||
* Only slightly modified by Acyd Burn
|
|
||||||
*/
|
|
||||||
class jabber
|
|
||||||
{
|
|
||||||
var $connection = null;
|
|
||||||
var $session = array();
|
|
||||||
var $timeout = 10;
|
|
||||||
|
|
||||||
var $server;
|
/** @var bool */
|
||||||
var $connect_server;
|
protected $enable_logging = true;
|
||||||
var $port;
|
|
||||||
var $username;
|
|
||||||
var $password;
|
|
||||||
var $use_ssl;
|
|
||||||
var $verify_peer;
|
|
||||||
var $verify_peer_name;
|
|
||||||
var $allow_self_signed;
|
|
||||||
var $resource = 'functions_jabber.phpbb.php';
|
|
||||||
|
|
||||||
var $enable_logging;
|
/** @var array */
|
||||||
var $log_array;
|
protected $features = [];
|
||||||
|
|
||||||
var $features = array();
|
/** @var array */
|
||||||
|
protected $jid = [];
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $log_array = [];
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $password;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $port;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $resource = 'functions_jabber.phpbb.php';
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $server;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $session = [];
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $stream_options = [];
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $timeout = 10;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $to = [];
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
protected $use_ssl = false;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $username;
|
||||||
|
|
||||||
/** @var string Stream close handshake */
|
/** @var string Stream close handshake */
|
||||||
private const STREAM_CLOSE_HANDSHAKE = '</stream:stream>';
|
private const STREAM_CLOSE_HANDSHAKE = '</stream:stream>';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Set initial parameter values
|
||||||
|
* To init correctly, username() call should go before server()
|
||||||
|
* and ssl() call should go before port() and stream_options() calls.
|
||||||
*
|
*
|
||||||
* @param string $server Jabber server
|
* Example:
|
||||||
* @param int $port Jabber server port
|
* $this->username($username)
|
||||||
* @param string $username Jabber username or JID
|
* ->password($password)
|
||||||
* @param string $password Jabber password
|
* ->ssl($use_ssl)
|
||||||
* @param bool $use_ssl Use ssl
|
* ->server($server)
|
||||||
* @param bool $verify_peer Verify SSL certificate
|
* ->port($port)
|
||||||
* @param bool $verify_peer_name Verify Jabber peer name
|
* ->stream_options(
|
||||||
* @param bool $allow_self_signed Allow self signed certificates
|
* 'verify_peer' => true,
|
||||||
|
* 'verify_peer_name' => true,
|
||||||
|
* 'allow_self_signed' => false,
|
||||||
|
* );
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct($server, $port, $username, $password, $use_ssl = false, $verify_peer = true, $verify_peer_name = true, $allow_self_signed = false)
|
public function init(): void
|
||||||
{
|
{
|
||||||
$this->connect_server = ($server) ? $server : 'localhost';
|
$this->username($this->config['jab_username'])
|
||||||
$this->port = ($port) ? $port : 5222;
|
->password($this->config['jab_password'])
|
||||||
|
->ssl((bool) $this->config['jab_use_ssl'])
|
||||||
// Get the server and the username
|
->server($this->config['jab_host'])
|
||||||
if (strpos($username, '@') === false)
|
->port($this->config['jab_port'])
|
||||||
{
|
->stream_options['ssl'] = [
|
||||||
$this->server = $this->connect_server;
|
'verify_peer' => $this->config['jab_verify_peer'],
|
||||||
$this->username = $username;
|
'verify_peer_name' => $this->config['jab_verify_peer_name'],
|
||||||
}
|
'allow_self_signed' => $this->config['jab_allow_self_signed'],
|
||||||
else
|
];
|
||||||
{
|
|
||||||
$jid = explode('@', $username, 2);
|
|
||||||
|
|
||||||
$this->username = $jid[0];
|
|
||||||
$this->server = $jid[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->password = $password;
|
/**
|
||||||
$this->use_ssl = ($use_ssl && self::can_use_ssl()) ? true : false;
|
* {@inheritDoc}
|
||||||
$this->verify_peer = $verify_peer;
|
*/
|
||||||
$this->verify_peer_name = $verify_peer_name;
|
public function get_id(): int
|
||||||
$this->allow_self_signed = $allow_self_signed;
|
{
|
||||||
|
return self::NOTIFY_IM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function get_queue_object_name(): string
|
||||||
|
{
|
||||||
|
return 'jabber';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function is_enabled(): bool
|
||||||
|
{
|
||||||
|
return
|
||||||
|
!empty($this->config['jab_enable']) &&
|
||||||
|
!empty($this->config['jab_host']) &&
|
||||||
|
!empty($this->config['jab_username']) &&
|
||||||
|
!empty($this->config['jab_password']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set ssl context options
|
||||||
|
* See http://php.net/manual/en/context.ssl.php
|
||||||
|
*
|
||||||
|
* @param array $options SSL context options array
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function stream_options(array $options = []): self
|
||||||
|
{
|
||||||
|
if ($this->use_ssl)
|
||||||
|
{
|
||||||
|
// Change default stream options if needed
|
||||||
|
$this->stream_options['ssl'] = array_merge($this->stream_options['ssl'], $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set password to connect to server
|
||||||
|
*
|
||||||
|
* @param string $password Password to connect to server
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function password(string $password = ''): self
|
||||||
|
{
|
||||||
|
$this->password = html_entity_decode($password, ENT_COMPAT);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set use of ssl to connect to server
|
||||||
|
*
|
||||||
|
* @param bool $use_ssl Flag indicating use of ssl to connect to server
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function ssl(bool $use_ssl = false): self
|
||||||
|
{
|
||||||
|
$this->use_ssl = $use_ssl && self::can_use_ssl();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set port to connect to server
|
||||||
|
* use_ssl flag should be set first
|
||||||
|
*
|
||||||
|
* @param int $port Port to connect to server
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function port(int $port = 5222): self
|
||||||
|
{
|
||||||
|
$this->port = ($port > 0) ? $port : 5222;
|
||||||
|
|
||||||
// Change port if we use SSL
|
// Change port if we use SSL
|
||||||
if ($this->port == 5222 && $this->use_ssl)
|
if ($this->port == 5222 && $this->use_ssl)
|
||||||
|
@ -97,22 +199,61 @@ class jabber
|
||||||
$this->port = 5223;
|
$this->port = 5223;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->enable_logging = true;
|
return $this;
|
||||||
$this->log_array = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Able to use the SSL functionality?
|
* Set username to connect to server
|
||||||
|
*
|
||||||
|
* @param string $username Username to connect to server
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public static function can_use_ssl()
|
public function username(string $username = ''): self
|
||||||
|
{
|
||||||
|
if (str_contains($username, '@'))
|
||||||
|
{
|
||||||
|
$this->jid = explode('@', $username, 2);
|
||||||
|
$this->username = $this->jid[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->username = $username;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set server to connect
|
||||||
|
* Username should be set first
|
||||||
|
*
|
||||||
|
* @param string $server Server to connect
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function server(string $server = ''): self
|
||||||
|
{
|
||||||
|
$this->connect_server = $server ?: 'localhost';
|
||||||
|
$this->server = $this->jid[1] ?? $this->connect_server;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if it's possible to use the SSL functionality
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function can_use_ssl(): bool
|
||||||
{
|
{
|
||||||
return @extension_loaded('openssl');
|
return @extension_loaded('openssl');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Able to use TLS?
|
* Check if it's possible to use TLS functionality
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function can_use_tls()
|
public static function can_use_tls(): bool
|
||||||
{
|
{
|
||||||
if (!@extension_loaded('openssl') || !function_exists('stream_socket_enable_crypto') || !function_exists('stream_get_meta_data') || !function_exists('stream_set_blocking') || !function_exists('stream_get_wrappers'))
|
if (!@extension_loaded('openssl') || !function_exists('stream_socket_enable_crypto') || !function_exists('stream_get_meta_data') || !function_exists('stream_set_blocking') || !function_exists('stream_get_wrappers'))
|
||||||
{
|
{
|
||||||
|
@ -135,19 +276,22 @@ class jabber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the resource which is used. No validation is done here, only escaping.
|
* Sets the resource which is used. No validation is done here, only escaping
|
||||||
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @access public
|
* @return void
|
||||||
*/
|
*/
|
||||||
function set_resource($name)
|
public function set_resource(string $name): void
|
||||||
{
|
{
|
||||||
$this->resource = $name;
|
$this->resource = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect
|
* Connect to the server
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function connect()
|
public function connect(): bool
|
||||||
{
|
{
|
||||||
/* if (!$this->check_jid($this->username . '@' . $this->server))
|
/* if (!$this->check_jid($this->username . '@' . $this->server))
|
||||||
{
|
{
|
||||||
|
@ -157,10 +301,10 @@ class jabber
|
||||||
|
|
||||||
$this->session['ssl'] = $this->use_ssl;
|
$this->session['ssl'] = $this->use_ssl;
|
||||||
|
|
||||||
if ($this->open_socket($this->connect_server, $this->port, $this->use_ssl, $this->verify_peer, $this->verify_peer_name, $this->allow_self_signed))
|
if ($this->open_socket($this->connect_server, $this->port))
|
||||||
{
|
{
|
||||||
$this->send("<?xml version='1.0' encoding='UTF-8' ?" . ">\n");
|
$this->send_xml("<?xml version='1.0' encoding='UTF-8' ?" . ">\n");
|
||||||
$this->send("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");
|
$this->send_xml("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -174,9 +318,11 @@ class jabber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect
|
* Disconnect from the server
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect(): bool
|
||||||
{
|
{
|
||||||
if ($this->connected())
|
if ($this->connected())
|
||||||
{
|
{
|
||||||
|
@ -195,7 +341,8 @@ class jabber
|
||||||
$this->add_to_log("Error: Unexpected stream close handshake reply ”{$stream_close_reply}”");
|
$this->add_to_log("Error: Unexpected stream close handshake reply ”{$stream_close_reply}”");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->session = array();
|
$this->session = [];
|
||||||
|
/** @psalm-suppress InvalidPropertyAssignmentValue */
|
||||||
return fclose($this->connection);
|
return fclose($this->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,20 +350,21 @@ class jabber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connected?
|
* Check if it's still connected to the server
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function connected()
|
public function connected(): bool
|
||||||
{
|
{
|
||||||
return (is_resource($this->connection) && !feof($this->connection)) ? true : false;
|
return is_resource($this->connection) && !feof($this->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates login (using data from contructor, after calling connect())
|
* Initiates login (using data from contructor, after calling connect())
|
||||||
* @access public
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function login()
|
public function login(): bool
|
||||||
{
|
{
|
||||||
if (empty($this->features))
|
if (empty($this->features))
|
||||||
{
|
{
|
||||||
|
@ -228,12 +376,178 @@ class jabber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send data to the Jabber server
|
* {@inheritDoc}
|
||||||
* @param string $xml
|
|
||||||
* @access public
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function send($xml)
|
public function set_addresses(array $user_row): void
|
||||||
|
{
|
||||||
|
if (isset($user_row['user_jabber']) && $user_row['user_jabber'])
|
||||||
|
{
|
||||||
|
$this->to($user_row['user_jabber'], (isset($user_row['username']) ? $user_row['username'] : ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets jabber contact to send message to
|
||||||
|
*
|
||||||
|
* @param string $address Jabber "To" recipient address
|
||||||
|
* @param string $realname Jabber "To" recipient name
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function to(string $address, string $realname = ''): void
|
||||||
|
{
|
||||||
|
// IM-Addresses could be empty
|
||||||
|
if (!trim($address))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pos = !empty($this->to) ? count($this->to) : 0;
|
||||||
|
$this->to[$pos]['uid'] = trim($address);
|
||||||
|
$this->to[$pos]['name'] = trim($realname);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets all the data (address, template file, etc) to default
|
||||||
|
*/
|
||||||
|
public function reset(): void
|
||||||
|
{
|
||||||
|
$this->subject = $this->msg = '';
|
||||||
|
$this->additional_headers = $this->to = [];
|
||||||
|
$this->use_queue = true;
|
||||||
|
unset($this->template);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function set_use_queue(bool $use_queue = true): void
|
||||||
|
{
|
||||||
|
$this->use_queue = !$this->config['jab_package_size'] ? false : $use_queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function process_queue(array &$queue_data): void
|
||||||
|
{
|
||||||
|
$queue_object_name = $this->get_queue_object_name();
|
||||||
|
$messages_count = count($queue_data[$queue_object_name]['data']);
|
||||||
|
|
||||||
|
if (!$this->is_enabled() || !$messages_count)
|
||||||
|
{
|
||||||
|
unset($queue_data[$queue_object_name]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@set_time_limit(0);
|
||||||
|
|
||||||
|
$package_size = $queue_data[$queue_object_name]['package_size'] ?? 0;
|
||||||
|
$num_items = (!$package_size || $messages_count < $package_size) ? $messages_count : $package_size;
|
||||||
|
|
||||||
|
for ($i = 0; $i < $num_items; $i++)
|
||||||
|
{
|
||||||
|
// Make variables available...
|
||||||
|
extract(array_shift($queue_data[$queue_object_name]['data']));
|
||||||
|
|
||||||
|
if (!$this->connect())
|
||||||
|
{
|
||||||
|
$this->error($this->user->lang['ERR_JAB_CONNECT'] . '<br />' . $this->get_log());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->login())
|
||||||
|
{
|
||||||
|
$this->error($this->user->lang['ERR_JAB_AUTH'] . '<br />' . $this->get_log());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($addresses as $address)
|
||||||
|
{
|
||||||
|
if ($this->send_message($address, $msg, $subject) === false)
|
||||||
|
{
|
||||||
|
$this->error($this->get_log());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No more data for this object? Unset it
|
||||||
|
if (!count($queue_data[$queue_object_name]['data']))
|
||||||
|
{
|
||||||
|
unset($queue_data[$queue_object_name]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function send(): bool
|
||||||
|
{
|
||||||
|
$this->prepare_message();
|
||||||
|
|
||||||
|
if (empty($this->to))
|
||||||
|
{
|
||||||
|
$this->add_to_log('Error: Could not send, recepient addresses undefined.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$addresses = [];
|
||||||
|
foreach ($this->to as $uid_ary)
|
||||||
|
{
|
||||||
|
$addresses[] = $uid_ary['uid'];
|
||||||
|
}
|
||||||
|
$addresses = array_unique($addresses);
|
||||||
|
|
||||||
|
if (!$this->use_queue)
|
||||||
|
{
|
||||||
|
if (!$this->connect())
|
||||||
|
{
|
||||||
|
$this->error($this->user->lang['ERR_JAB_CONNECT'] . '<br />' . $this->get_log());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->login())
|
||||||
|
{
|
||||||
|
$this->error($this->user->lang['ERR_JAB_AUTH'] . '<br />' . $this->get_log());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($addresses as $address)
|
||||||
|
{
|
||||||
|
if ($this->send_message($address, $this->msg, $this->subject) === false)
|
||||||
|
{
|
||||||
|
$this->error($this->get_log());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->disconnect();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->queue->init('jabber', $this->config['jab_package_size']);
|
||||||
|
$this->queue->put('jabber', [
|
||||||
|
'addresses' => $addresses,
|
||||||
|
'subject' => $this->subject,
|
||||||
|
'msg' => $this->msg,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
unset($addresses);
|
||||||
|
|
||||||
|
$this->reset();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send data to the Jabber server
|
||||||
|
*
|
||||||
|
* @param string $xml
|
||||||
|
* @return int|bool
|
||||||
|
*/
|
||||||
|
public function send_xml(string $xml): int|bool
|
||||||
{
|
{
|
||||||
if ($this->connected())
|
if ($this->connected())
|
||||||
{
|
{
|
||||||
|
@ -248,17 +562,14 @@ class jabber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OpenSocket
|
* Open socket
|
||||||
* @param string $server host to connect to
|
*
|
||||||
* @param int $port port number
|
* @param string $server Host to connect to
|
||||||
* @param bool $use_ssl use ssl or not
|
* @param int $port Port number
|
||||||
* @param bool $verify_peer verify ssl certificate
|
*
|
||||||
* @param bool $verify_peer_name verify peer name
|
|
||||||
* @param bool $allow_self_signed allow self-signed ssl certificates
|
|
||||||
* @access public
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function open_socket($server, $port, $use_ssl, $verify_peer, $verify_peer_name, $allow_self_signed)
|
public function open_socket(string $server, int $port): bool
|
||||||
{
|
{
|
||||||
if (@function_exists('dns_get_record'))
|
if (@function_exists('dns_get_record'))
|
||||||
{
|
{
|
||||||
|
@ -269,21 +580,8 @@ class jabber
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = array();
|
$remote_socket = $this->use_ssl ? 'ssl://' . $server . ':' . $port : $server . ':' . $port;
|
||||||
|
$socket_context = stream_context_create($this->stream_options);
|
||||||
if ($use_ssl)
|
|
||||||
{
|
|
||||||
$remote_socket = 'ssl://' . $server . ':' . $port;
|
|
||||||
|
|
||||||
// Set ssl context options, see http://php.net/manual/en/context.ssl.php
|
|
||||||
$options['ssl'] = array('verify_peer' => $verify_peer, 'verify_peer_name' => $verify_peer_name, 'allow_self_signed' => $allow_self_signed);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$remote_socket = $server . ':' . $port;
|
|
||||||
}
|
|
||||||
|
|
||||||
$socket_context = stream_context_create($options);
|
|
||||||
|
|
||||||
if ($this->connection = @stream_socket_client($remote_socket, $errorno, $errorstr, $this->timeout, STREAM_CLIENT_CONNECT, $socket_context))
|
if ($this->connection = @stream_socket_client($remote_socket, $errorno, $errorstr, $this->timeout, STREAM_CLIENT_CONNECT, $socket_context))
|
||||||
{
|
{
|
||||||
|
@ -299,9 +597,11 @@ class jabber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return log
|
* Get connection log
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_log()
|
public function get_log(): string
|
||||||
{
|
{
|
||||||
if ($this->enable_logging && count($this->log_array))
|
if ($this->enable_logging && count($this->log_array))
|
||||||
{
|
{
|
||||||
|
@ -313,8 +613,11 @@ class jabber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add information to log
|
* Add information to log
|
||||||
|
*
|
||||||
|
* @param string $string Log entry
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function add_to_log($string)
|
protected function add_to_log(string $string): void
|
||||||
{
|
{
|
||||||
if ($this->enable_logging)
|
if ($this->enable_logging)
|
||||||
{
|
{
|
||||||
|
@ -325,10 +628,12 @@ class jabber
|
||||||
/**
|
/**
|
||||||
* Listens to the connection until it gets data or the timeout is reached.
|
* Listens to the connection until it gets data or the timeout is reached.
|
||||||
* Thus, it should only be called if data is expected to be received.
|
* Thus, it should only be called if data is expected to be received.
|
||||||
* @access public
|
*
|
||||||
* @return mixed either false for timeout or an array with the received data
|
* @param int $timeout Connection timeout
|
||||||
|
* @param bool $wait Flag indicating if it should wait for the responce until timeout
|
||||||
|
* @return bool|array Either false for timeout or an array with the received data
|
||||||
*/
|
*/
|
||||||
function listen($timeout = 10, $wait = false)
|
public function listen(int $timeout = 10, bool $wait = false): bool|array
|
||||||
{
|
{
|
||||||
if (!$this->connected())
|
if (!$this->connected())
|
||||||
{
|
{
|
||||||
|
@ -358,11 +663,11 @@ class jabber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates account registration (based on data used for contructor)
|
* Initiates account registration (based on data used for constructor)
|
||||||
* @access public
|
*
|
||||||
* @return bool
|
* @return bool|null
|
||||||
*/
|
*/
|
||||||
function register()
|
public function register(): bool|null
|
||||||
{
|
{
|
||||||
if (!isset($this->session['id']) || isset($this->session['jid']))
|
if (!isset($this->session['id']) || isset($this->session['jid']))
|
||||||
{
|
{
|
||||||
|
@ -370,19 +675,19 @@ class jabber
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->send("<iq type='get' id='reg_1'><query xmlns='jabber:iq:register'/></iq>");
|
$this->send_xml("<iq type='get' id='reg_1'><query xmlns='jabber:iq:register'/></iq>");
|
||||||
return $this->response($this->listen());
|
return $this->response($this->listen());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets account presence. No additional info required (default is "online" status)
|
* Sets account presence. No additional info required (default is "online" status)
|
||||||
* @param $message online, offline...
|
*
|
||||||
* @param $type dnd, away, chat, xa or nothing
|
* @param string $message Account status (online, offline)
|
||||||
* @param $unavailable set this to true if you want to become unavailable
|
* @param string $type Status type (dnd, away, chat, xa or nothing)
|
||||||
* @access public
|
* @param bool $unavailable Set to true to make unavailable status
|
||||||
* @return bool
|
* @return int|bool
|
||||||
*/
|
*/
|
||||||
function send_presence($message = '', $type = '', $unavailable = false)
|
function send_presence(string $message = '', string $type = '', bool $unavailable = false): int|bool
|
||||||
{
|
{
|
||||||
if (!isset($this->session['jid']))
|
if (!isset($this->session['jid']))
|
||||||
{
|
{
|
||||||
|
@ -398,18 +703,18 @@ class jabber
|
||||||
|
|
||||||
$this->session['sent_presence'] = !$unavailable;
|
$this->session['sent_presence'] = !$unavailable;
|
||||||
|
|
||||||
return $this->send("<presence$unavailable>" . $type . $message . '</presence>');
|
return $this->send_xml("<presence$unavailable>" . $type . $message . '</presence>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This handles all the different XML elements
|
* This handles all the different XML elements
|
||||||
|
*
|
||||||
* @param array $xml
|
* @param array $xml
|
||||||
* @access public
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function response($xml)
|
function response(array $xml): bool
|
||||||
{
|
{
|
||||||
if (!is_array($xml) || !count($xml))
|
if (!count($xml))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -422,20 +727,17 @@ class jabber
|
||||||
{
|
{
|
||||||
$this->response(array($key => $value));
|
$this->response(array($key => $value));
|
||||||
}
|
}
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else if (is_array(reset($xml)) && count(reset($xml)) > 1)
|
||||||
{
|
{
|
||||||
// or even multiple elements of the same type?
|
// or even multiple elements of the same type?
|
||||||
// array('message' => array(0 => ..., 1 => ...))
|
// array('message' => array(0 => ..., 1 => ...))
|
||||||
if (is_array(reset($xml)) && count(reset($xml)) > 1)
|
|
||||||
{
|
|
||||||
foreach (reset($xml) as $value)
|
foreach (reset($xml) as $value)
|
||||||
{
|
{
|
||||||
$this->response(array(key($xml) => array(0 => $value)));
|
$this->response(array(key($xml) => array(0 => $value)));
|
||||||
}
|
}
|
||||||
return;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key($xml))
|
switch (key($xml))
|
||||||
|
@ -467,6 +769,7 @@ class jabber
|
||||||
{
|
{
|
||||||
return $this->response($this->features);
|
return $this->response($this->features);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'stream:features':
|
case 'stream:features':
|
||||||
|
@ -476,7 +779,7 @@ class jabber
|
||||||
// session required?
|
// session required?
|
||||||
$this->session['sess_required'] = isset($xml['stream:features'][0]['#']['session']);
|
$this->session['sess_required'] = isset($xml['stream:features'][0]['#']['session']);
|
||||||
|
|
||||||
$this->send("<iq type='set' id='bind_1'>
|
$this->send_xml("<iq type='set' id='bind_1'>
|
||||||
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
|
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
|
||||||
<resource>" . utf8_htmlspecialchars($this->resource) . '</resource>
|
<resource>" . utf8_htmlspecialchars($this->resource) . '</resource>
|
||||||
</bind>
|
</bind>
|
||||||
|
@ -488,7 +791,7 @@ class jabber
|
||||||
if (!$this->session['ssl'] && self::can_use_tls() && self::can_use_ssl() && isset($xml['stream:features'][0]['#']['starttls']))
|
if (!$this->session['ssl'] && self::can_use_tls() && self::can_use_ssl() && isset($xml['stream:features'][0]['#']['starttls']))
|
||||||
{
|
{
|
||||||
$this->add_to_log('Switching to TLS.');
|
$this->add_to_log('Switching to TLS.');
|
||||||
$this->send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\n");
|
$this->send_xml("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\n");
|
||||||
return $this->response($this->listen());
|
return $this->response($this->listen());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,18 +817,18 @@ class jabber
|
||||||
|
|
||||||
if (in_array('DIGEST-MD5', $methods))
|
if (in_array('DIGEST-MD5', $methods))
|
||||||
{
|
{
|
||||||
$this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'/>");
|
$this->send_xml("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'/>");
|
||||||
}
|
}
|
||||||
else if (in_array('PLAIN', $methods) && ($this->session['ssl'] || !empty($this->session['tls'])))
|
else if (in_array('PLAIN', $methods) && ($this->session['ssl'] || !empty($this->session['tls'])))
|
||||||
{
|
{
|
||||||
// http://www.ietf.org/rfc/rfc4616.txt (PLAIN SASL Mechanism)
|
// http://www.ietf.org/rfc/rfc4616.txt (PLAIN SASL Mechanism)
|
||||||
$this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>"
|
$this->send_xml("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>"
|
||||||
. base64_encode($this->username . '@' . $this->server . chr(0) . $this->username . chr(0) . $this->password) .
|
. base64_encode($this->username . '@' . $this->server . chr(0) . $this->username . chr(0) . $this->password) .
|
||||||
'</auth>');
|
'</auth>');
|
||||||
}
|
}
|
||||||
else if (in_array('ANONYMOUS', $methods))
|
else if (in_array('ANONYMOUS', $methods))
|
||||||
{
|
{
|
||||||
$this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>");
|
$this->send_xml("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -562,7 +865,7 @@ class jabber
|
||||||
// second challenge?
|
// second challenge?
|
||||||
if (isset($decoded['rspauth']))
|
if (isset($decoded['rspauth']))
|
||||||
{
|
{
|
||||||
$this->send("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>");
|
$this->send_xml("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -589,7 +892,7 @@ class jabber
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->send("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>" . base64_encode($this->implode_data($response)) . '</response>');
|
$this->send_xml("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>" . base64_encode($this->implode_data($response)) . '</response>');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response($this->listen());
|
return $this->response($this->listen());
|
||||||
|
@ -616,15 +919,15 @@ class jabber
|
||||||
$this->session['tls'] = true;
|
$this->session['tls'] = true;
|
||||||
|
|
||||||
// new stream
|
// new stream
|
||||||
$this->send("<?xml version='1.0' encoding='UTF-8' ?" . ">\n");
|
$this->send_xml("<?xml version='1.0' encoding='UTF-8' ?" . ">\n");
|
||||||
$this->send("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");
|
$this->send_xml("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");
|
||||||
|
|
||||||
return $this->response($this->listen());
|
return $this->response($this->listen());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'success':
|
case 'success':
|
||||||
// Yay, authentication successful.
|
// Yay, authentication successful.
|
||||||
$this->send("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");
|
$this->send_xml("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\n");
|
||||||
$this->session['authenticated'] = true;
|
$this->session['authenticated'] = true;
|
||||||
|
|
||||||
// we have to wait for another response
|
// we have to wait for another response
|
||||||
|
@ -647,7 +950,7 @@ class jabber
|
||||||
// and (maybe) yet another request to be able to send messages *finally*
|
// and (maybe) yet another request to be able to send messages *finally*
|
||||||
if ($this->session['sess_required'])
|
if ($this->session['sess_required'])
|
||||||
{
|
{
|
||||||
$this->send("<iq to='{$this->server}' type='set' id='sess_1'>
|
$this->send_xml("<iq to='{$this->server}' type='set' id='sess_1'>
|
||||||
<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
|
<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
|
||||||
</iq>");
|
</iq>");
|
||||||
return $this->response($this->listen());
|
return $this->response($this->listen());
|
||||||
|
@ -661,7 +964,7 @@ class jabber
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'reg_1':
|
case 'reg_1':
|
||||||
$this->send("<iq type='set' id='reg_2'>
|
$this->send_xml("<iq type='set' id='reg_2'>
|
||||||
<query xmlns='jabber:iq:register'>
|
<query xmlns='jabber:iq:register'>
|
||||||
<username>" . utf8_htmlspecialchars($this->username) . "</username>
|
<username>" . utf8_htmlspecialchars($this->username) . "</username>
|
||||||
<password>" . utf8_htmlspecialchars($this->password) . "</password>
|
<password>" . utf8_htmlspecialchars($this->password) . "</password>
|
||||||
|
@ -706,6 +1009,7 @@ class jabber
|
||||||
$message['subject'] = $xml['message'][0]['#']['subject'][0]['#'];
|
$message['subject'] = $xml['message'][0]['#']['subject'][0]['#'];
|
||||||
}
|
}
|
||||||
$this->session['messages'][] = $message;
|
$this->session['messages'][] = $message;
|
||||||
|
return true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -716,7 +1020,17 @@ class jabber
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function send_message($to, $text, $subject = '', $type = 'normal')
|
/**
|
||||||
|
* Send Jabber message
|
||||||
|
*
|
||||||
|
* @param string $to Recepient usermane
|
||||||
|
* @param string $text Message text
|
||||||
|
* @param string $subject Message subject
|
||||||
|
* @param string $type Message type
|
||||||
|
*
|
||||||
|
* @return int|bool
|
||||||
|
*/
|
||||||
|
public function send_message(string $to, string $text, string $subject = '', string $type = 'normal'): int|bool
|
||||||
{
|
{
|
||||||
if (!isset($this->session['jid']))
|
if (!isset($this->session['jid']))
|
||||||
{
|
{
|
||||||
|
@ -728,7 +1042,7 @@ class jabber
|
||||||
$type = 'normal';
|
$type = 'normal';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->send("<message from='" . utf8_htmlspecialchars($this->session['jid']) . "' to='" . utf8_htmlspecialchars($to) . "' type='$type' id='" . uniqid('msg') . "'>
|
return $this->send_xml("<message from='" . utf8_htmlspecialchars($this->session['jid']) . "' to='" . utf8_htmlspecialchars($to) . "' type='$type' id='" . uniqid('msg') . "'>
|
||||||
<subject>" . utf8_htmlspecialchars($subject) . "</subject>
|
<subject>" . utf8_htmlspecialchars($subject) . "</subject>
|
||||||
<body>" . utf8_htmlspecialchars($text) . "</body>
|
<body>" . utf8_htmlspecialchars($text) . "</body>
|
||||||
</message>"
|
</message>"
|
||||||
|
@ -737,11 +1051,11 @@ class jabber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypts a password as in RFC 2831
|
* Encrypts a password as in RFC 2831
|
||||||
|
*
|
||||||
* @param array $data Needs data from the client-server connection
|
* @param array $data Needs data from the client-server connection
|
||||||
* @access public
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function encrypt_password($data)
|
public function encrypt_password(array $data): string
|
||||||
{
|
{
|
||||||
// let's me think about <challenge> again...
|
// let's me think about <challenge> again...
|
||||||
foreach (array('realm', 'cnonce', 'digest-uri') as $key)
|
foreach (array('realm', 'cnonce', 'digest-uri') as $key)
|
||||||
|
@ -770,12 +1084,12 @@ class jabber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parse_data like a="b",c="d",... or like a="a, b", c, d="e", f=g,...
|
* Parse data string like a="b",c="d",... or like a="a, b", c, d="e", f=g,...
|
||||||
|
*
|
||||||
* @param string $data
|
* @param string $data
|
||||||
* @access public
|
|
||||||
* @return array a => b ...
|
* @return array a => b ...
|
||||||
*/
|
*/
|
||||||
function parse_data($data)
|
public function parse_data(string $data): array
|
||||||
{
|
{
|
||||||
$data = explode(',', $data);
|
$data = explode(',', $data);
|
||||||
$pairs = array();
|
$pairs = array();
|
||||||
|
@ -802,12 +1116,12 @@ class jabber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* opposite of jabber::parse_data()
|
* The opposite of jabber::parse_data()
|
||||||
* @param array $data
|
*
|
||||||
* @access public
|
* @param array $data Data array
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function implode_data($data)
|
public function implode_data(array $data): string
|
||||||
{
|
{
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ($data as $key => $value)
|
foreach ($data as $key => $value)
|
||||||
|
@ -821,8 +1135,13 @@ class jabber
|
||||||
* xmlize()
|
* xmlize()
|
||||||
* @author Hans Anderson
|
* @author Hans Anderson
|
||||||
* @copyright Hans Anderson / http://www.hansanderson.com/php/xml/
|
* @copyright Hans Anderson / http://www.hansanderson.com/php/xml/
|
||||||
|
*
|
||||||
|
* @param string $data Data string
|
||||||
|
* @param string|int|bool $skip_white New XML parser option value
|
||||||
|
* @param string $encoding Encoding value
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function xmlize($data, $skip_white = 1, $encoding = 'UTF-8')
|
function xmlize(string $data, string|int|bool $skip_white = 1, string $encoding = 'UTF-8'): array
|
||||||
{
|
{
|
||||||
$data = trim($data);
|
$data = trim($data);
|
||||||
|
|
||||||
|
@ -857,8 +1176,12 @@ class jabber
|
||||||
* _xml_depth()
|
* _xml_depth()
|
||||||
* @author Hans Anderson
|
* @author Hans Anderson
|
||||||
* @copyright Hans Anderson / http://www.hansanderson.com/php/xml/
|
* @copyright Hans Anderson / http://www.hansanderson.com/php/xml/
|
||||||
|
*
|
||||||
|
* @param array $vals XML data array
|
||||||
|
* @param int $i XML tags depth level
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _xml_depth($vals, &$i)
|
function _xml_depth(array $vals, int &$i): array
|
||||||
{
|
{
|
||||||
$children = array();
|
$children = array();
|
||||||
|
|
68
phpBB/phpbb/messenger/method/messenger_interface.php
Normal file
68
phpBB/phpbb/messenger/method/messenger_interface.php
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\messenger\method;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Messenger method interface class
|
||||||
|
*/
|
||||||
|
interface messenger_interface
|
||||||
|
{
|
||||||
|
/** @var int Email notify method used */
|
||||||
|
public const NOTIFY_EMAIL = 0;
|
||||||
|
|
||||||
|
/** @var int Instant messaging (Jabber) notify method used */
|
||||||
|
public const NOTIFY_IM = 1;
|
||||||
|
|
||||||
|
/** @var int Both notify methods used */
|
||||||
|
public const NOTIFY_BOTH = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get messenger method id
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function get_id(): int;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the messenger method is enabled
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function is_enabled(): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up subject for the message
|
||||||
|
*
|
||||||
|
* @param string $subject Email subject
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function subject(string $subject = ''): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send out messages
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function send(): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add error message to log
|
||||||
|
*
|
||||||
|
* @param string $msg Error message text
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function error(string $msg): void;
|
||||||
|
}
|
213
phpBB/phpbb/messenger/queue.php
Normal file
213
phpBB/phpbb/messenger/queue.php
Normal file
|
@ -0,0 +1,213 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\messenger;
|
||||||
|
|
||||||
|
use phpbb\config\config;
|
||||||
|
use phpbb\event\dispatcher;
|
||||||
|
use phpbb\di\service_collection;
|
||||||
|
use phpbb\filesystem\filesystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handling messenger file queue
|
||||||
|
*/
|
||||||
|
class queue
|
||||||
|
{
|
||||||
|
/** @var string */
|
||||||
|
protected $cache_file;
|
||||||
|
|
||||||
|
/** @var config */
|
||||||
|
protected $config;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $data = [];
|
||||||
|
|
||||||
|
/** @var dispatcher */
|
||||||
|
protected $dispatcher;
|
||||||
|
|
||||||
|
/** @var \phpbb\filesystem\filesystem_interface */
|
||||||
|
protected $filesystem;
|
||||||
|
|
||||||
|
/** @var service_collection */
|
||||||
|
protected $messenger_method_collection;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $queue_data = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Messenger queue constructor.
|
||||||
|
*
|
||||||
|
* @param config $config
|
||||||
|
* @param dispatcher $dispatcher
|
||||||
|
* @param service_collection $messenger_method_collection
|
||||||
|
* @param string $cache_file
|
||||||
|
*/
|
||||||
|
public function __construct(config $config, dispatcher $dispatcher, service_collection $messenger_method_collection, $cache_file)
|
||||||
|
{
|
||||||
|
$this->config = $config;
|
||||||
|
$this->dispatcher = $dispatcher;
|
||||||
|
$this->messenger_method_collection = $messenger_method_collection;
|
||||||
|
$this->filesystem = new filesystem();
|
||||||
|
$this->cache_file = $cache_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init a queue object
|
||||||
|
*
|
||||||
|
* @param string $object Queue object type: email/jabber/etc
|
||||||
|
* @param int $package_size Size of the messenger package to send
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function init(string $object, int $package_size): void
|
||||||
|
{
|
||||||
|
$this->data[$object] = [];
|
||||||
|
$this->data[$object]['package_size'] = $package_size;
|
||||||
|
$this->data[$object]['data'] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put message into the messenger file queue
|
||||||
|
*
|
||||||
|
* @param string $object Queue object type: email/jabber/etc
|
||||||
|
* @param array $message_data Message data to send
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function put(string $object, array $message_data): void
|
||||||
|
{
|
||||||
|
$this->data[$object]['data'][] = $message_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the messenger file queue (using lock file)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function process(): void
|
||||||
|
{
|
||||||
|
$lock = new \phpbb\lock\flock($this->cache_file);
|
||||||
|
$lock->acquire();
|
||||||
|
|
||||||
|
// avoid races, check file existence once
|
||||||
|
$have_cache_file = file_exists($this->cache_file);
|
||||||
|
if (!$have_cache_file || $this->config['last_queue_run'] > time() - $this->config['queue_interval'])
|
||||||
|
{
|
||||||
|
if (!$have_cache_file)
|
||||||
|
{
|
||||||
|
$this->config->set('last_queue_run', time(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
$lock->release();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->config->set('last_queue_run', time(), false);
|
||||||
|
|
||||||
|
include($this->cache_file);
|
||||||
|
|
||||||
|
/** @psalm-suppress InvalidTemplateParam */
|
||||||
|
$messenger_collection_iterator = $this->messenger_method_collection->getIterator();
|
||||||
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
|
{
|
||||||
|
if (isset($this->queue_data[$messenger_method->get_queue_object_name()]))
|
||||||
|
{
|
||||||
|
$messenger_method->process_queue($this->queue_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!count($this->queue_data))
|
||||||
|
{
|
||||||
|
@unlink($this->cache_file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($fp = @fopen($this->cache_file, 'wb'))
|
||||||
|
{
|
||||||
|
fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>");
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
if (function_exists('opcache_invalidate'))
|
||||||
|
{
|
||||||
|
@opcache_invalidate($this->cache_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$this->filesystem->phpbb_chmod($this->cache_file, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE);
|
||||||
|
}
|
||||||
|
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$lock->release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save message data to the messenger file queue
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function save(): void
|
||||||
|
{
|
||||||
|
if (!count($this->data))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$lock = new \phpbb\lock\flock($this->cache_file);
|
||||||
|
$lock->acquire();
|
||||||
|
|
||||||
|
if (file_exists($this->cache_file))
|
||||||
|
{
|
||||||
|
include($this->cache_file);
|
||||||
|
|
||||||
|
foreach ($this->queue_data as $object => $data_ary)
|
||||||
|
{
|
||||||
|
if (isset($this->data[$object]) && count($this->data[$object]))
|
||||||
|
{
|
||||||
|
$this->data[$object]['data'] = array_merge($data_ary['data'], $this->data[$object]['data']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->data[$object]['data'] = $data_ary['data'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($fp = @fopen($this->cache_file, 'w'))
|
||||||
|
{
|
||||||
|
fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>");
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
if (function_exists('opcache_invalidate'))
|
||||||
|
{
|
||||||
|
@opcache_invalidate($this->cache_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$this->filesystem->phpbb_chmod($this->cache_file, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE);
|
||||||
|
}
|
||||||
|
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->data = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$lock->release();
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,6 +14,12 @@
|
||||||
namespace phpbb\notification\method;
|
namespace phpbb\notification\method;
|
||||||
|
|
||||||
use phpbb\notification\type\type_interface;
|
use phpbb\notification\type\type_interface;
|
||||||
|
use phpbb\user;
|
||||||
|
use phpbb\user_loader;
|
||||||
|
use phpbb\config\config;
|
||||||
|
use phpbb\db\driver\driver_interface;
|
||||||
|
use phpbb\di\service_collection;
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Email notification method class
|
* Email notification method class
|
||||||
|
@ -22,32 +28,45 @@ use phpbb\notification\type\type_interface;
|
||||||
|
|
||||||
class email extends \phpbb\notification\method\messenger_base
|
class email extends \phpbb\notification\method\messenger_base
|
||||||
{
|
{
|
||||||
/** @var \phpbb\user */
|
/** @var user */
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
/** @var \phpbb\config\config */
|
/** @var config */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
/** @var \phpbb\db\driver\driver_interface */
|
/** @var driver_interface */
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
/** @var string Notification emails table */
|
/** @var string Notification emails table */
|
||||||
protected $notification_emails_table;
|
protected $notification_emails_table;
|
||||||
|
|
||||||
|
/** @var service_collection */
|
||||||
|
protected $messenger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification Method email Constructor
|
* Notification Method email Constructor
|
||||||
*
|
*
|
||||||
* @param \phpbb\user_loader $user_loader
|
* @param user_loader $user_loader
|
||||||
* @param \phpbb\user $user
|
* @param user $user
|
||||||
* @param \phpbb\config\config $config
|
* @param config $config
|
||||||
* @param \phpbb\db\driver\driver_interface $db
|
* @param driver_interface $db
|
||||||
* @param string $phpbb_root_path
|
* @param string $phpbb_root_path
|
||||||
* @param string $php_ext
|
* @param string $php_ext
|
||||||
* @param string $notification_emails_table
|
* @param string $notification_emails_table
|
||||||
|
* @param service_collection $messenger
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\user_loader $user_loader, \phpbb\user $user, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext, $notification_emails_table)
|
public function __construct(
|
||||||
|
user_loader $user_loader,
|
||||||
|
user $user,
|
||||||
|
config $config,
|
||||||
|
driver_interface $db,
|
||||||
|
$phpbb_root_path,
|
||||||
|
$php_ext,
|
||||||
|
$notification_emails_table,
|
||||||
|
service_collection $messenger
|
||||||
|
)
|
||||||
{
|
{
|
||||||
parent::__construct($user_loader, $phpbb_root_path, $php_ext);
|
parent::__construct($messenger, $user_loader, $phpbb_root_path, $php_ext);
|
||||||
|
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
@ -117,7 +136,7 @@ class email extends \phpbb\notification\method\messenger_base
|
||||||
|
|
||||||
$insert_buffer->flush();
|
$insert_buffer->flush();
|
||||||
|
|
||||||
$this->notify_using_messenger(NOTIFY_EMAIL);
|
$this->notify_using_messenger(messenger_interface::NOTIFY_EMAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
namespace phpbb\notification\method;
|
namespace phpbb\notification\method;
|
||||||
|
|
||||||
use phpbb\notification\type\type_interface;
|
use phpbb\notification\type\type_interface;
|
||||||
|
use phpbb\user;
|
||||||
|
use phpbb\user_loader;
|
||||||
|
use phpbb\config\config;
|
||||||
|
use phpbb\di\service_collection;
|
||||||
|
use phpbb\messenger\method\messenger_interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jabber notification method class
|
* Jabber notification method class
|
||||||
|
@ -22,24 +27,28 @@ use phpbb\notification\type\type_interface;
|
||||||
|
|
||||||
class jabber extends \phpbb\notification\method\messenger_base
|
class jabber extends \phpbb\notification\method\messenger_base
|
||||||
{
|
{
|
||||||
/** @var \phpbb\user */
|
/** @var user */
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
/** @var \phpbb\config\config */
|
/** @var config */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
/** @var service_collection */
|
||||||
|
protected $messenger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification Method jabber Constructor
|
* Notification Method jabber Constructor
|
||||||
*
|
*
|
||||||
* @param \phpbb\user_loader $user_loader
|
* @param user_loader $user_loader
|
||||||
* @param \phpbb\user $user
|
* @param user $user
|
||||||
* @param \phpbb\config\config $config
|
* @param config $config
|
||||||
* @param string $phpbb_root_path
|
* @param string $phpbb_root_path
|
||||||
* @param string $php_ext
|
* @param string $php_ext
|
||||||
|
* @param service_collection $messenger
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\user_loader $user_loader, \phpbb\user $user, \phpbb\config\config $config, $phpbb_root_path, $php_ext)
|
public function __construct(user_loader $user_loader, user $user, config $config, $phpbb_root_path, $php_ext, service_collection $messenger)
|
||||||
{
|
{
|
||||||
parent::__construct($user_loader, $phpbb_root_path, $php_ext);
|
parent::__construct($messenger, $user_loader, $phpbb_root_path, $php_ext);
|
||||||
|
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
@ -90,6 +99,6 @@ class jabber extends \phpbb\notification\method\messenger_base
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->notify_using_messenger(NOTIFY_IM, 'short/');
|
$this->notify_using_messenger(messenger_interface::NOTIFY_IM, 'short/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
namespace phpbb\notification\method;
|
namespace phpbb\notification\method;
|
||||||
|
|
||||||
use phpbb\notification\type\type_interface;
|
use phpbb\notification\type\type_interface;
|
||||||
|
use phpbb\di\service_collection;
|
||||||
|
use phpbb\user_loader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract notification method handling email and jabber notifications
|
* Abstract notification method handling email and jabber notifications
|
||||||
|
@ -21,7 +23,10 @@ use phpbb\notification\type\type_interface;
|
||||||
*/
|
*/
|
||||||
abstract class messenger_base extends \phpbb\notification\method\base
|
abstract class messenger_base extends \phpbb\notification\method\base
|
||||||
{
|
{
|
||||||
/** @var \phpbb\user_loader */
|
/** @var service_collection */
|
||||||
|
protected $messenger;
|
||||||
|
|
||||||
|
/** @var user_loader */
|
||||||
protected $user_loader;
|
protected $user_loader;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
@ -33,12 +38,14 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
||||||
/**
|
/**
|
||||||
* Notification Method Board Constructor
|
* Notification Method Board Constructor
|
||||||
*
|
*
|
||||||
* @param \phpbb\user_loader $user_loader
|
* @param service_collection $messenger
|
||||||
|
* @param user_loader $user_loader
|
||||||
* @param string $phpbb_root_path
|
* @param string $phpbb_root_path
|
||||||
* @param string $php_ext
|
* @param string $php_ext
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\user_loader $user_loader, $phpbb_root_path, $php_ext)
|
public function __construct(service_collection $messenger, user_loader $user_loader, $phpbb_root_path, $php_ext)
|
||||||
{
|
{
|
||||||
|
$this->messenger = $messenger;
|
||||||
$this->user_loader = $user_loader;
|
$this->user_loader = $user_loader;
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->php_ext = $php_ext;
|
$this->php_ext = $php_ext;
|
||||||
|
@ -60,7 +67,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
||||||
/**
|
/**
|
||||||
* Notify using phpBB messenger
|
* Notify using phpBB messenger
|
||||||
*
|
*
|
||||||
* @param int $notify_method Notify method for messenger (e.g. NOTIFY_IM)
|
* @param int $notify_method Notify method for messenger (e.g. \phpbb\messenger\method\messenger_interface::NOTIFY_IM)
|
||||||
* @param string $template_dir_prefix Base directory to prepend to the email template name
|
* @param string $template_dir_prefix Base directory to prepend to the email template name
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -73,13 +80,13 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load all users we want to notify (we need their email address)
|
// Load all users we want to notify (we need their email address)
|
||||||
$user_ids = array();
|
$user_ids = [];
|
||||||
foreach ($this->queue as $notification)
|
foreach ($this->queue as $notification)
|
||||||
{
|
{
|
||||||
$user_ids[] = $notification->user_id;
|
$user_ids[] = $notification->user_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We do not send emails to banned users
|
// We do not notify banned users
|
||||||
if (!function_exists('phpbb_get_banned_user_ids'))
|
if (!function_exists('phpbb_get_banned_user_ids'))
|
||||||
{
|
{
|
||||||
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
|
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
|
||||||
|
@ -89,14 +96,9 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
||||||
// Load all the users we need
|
// Load all the users we need
|
||||||
$this->user_loader->load_users(array_diff($user_ids, $banned_users), array(USER_IGNORE));
|
$this->user_loader->load_users(array_diff($user_ids, $banned_users), array(USER_IGNORE));
|
||||||
|
|
||||||
// Load the messenger
|
// Time to go through the queue and send notifications
|
||||||
if (!class_exists('messenger'))
|
$messenger_collection_iterator = $this->messenger->getIterator();
|
||||||
{
|
|
||||||
include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
|
|
||||||
}
|
|
||||||
$messenger = new \messenger();
|
|
||||||
|
|
||||||
// Time to go through the queue and send emails
|
|
||||||
/** @var type_interface $notification */
|
/** @var type_interface $notification */
|
||||||
foreach ($this->queue as $notification)
|
foreach ($this->queue as $notification)
|
||||||
{
|
{
|
||||||
|
@ -112,21 +114,27 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$messenger->template($notification->get_email_template(), $user['user_lang'], '', $template_dir_prefix);
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
|
{
|
||||||
$messenger->set_addresses($user);
|
if ($messenger_method->get_id() == $notify_method || $notify_method == $messenger_method::NOTIFY_BOTH)
|
||||||
|
{
|
||||||
$messenger->assign_vars(array_merge(array(
|
$messenger_method->template($notification->get_email_template(), $user['user_lang'], '', $template_dir_prefix);
|
||||||
|
$messenger_method->set_addresses($user);
|
||||||
|
$messenger_method->assign_vars(array_merge([
|
||||||
'USERNAME' => $user['username'],
|
'USERNAME' => $user['username'],
|
||||||
|
|
||||||
'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications&mode=notification_options',
|
'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications&mode=notification_options',
|
||||||
), $notification->get_email_template_variables()));
|
], $notification->get_email_template_variables()));
|
||||||
|
|
||||||
$messenger->send($notify_method);
|
$messenger_method->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the queue in the messenger class (has to be called or these emails could be lost?)
|
// Save the queue in the messenger method class (has to be called or these messages could be lost)
|
||||||
$messenger->save_queue();
|
foreach ($messenger_collection_iterator as $messenger_method)
|
||||||
|
{
|
||||||
|
$messenger_method->save_queue();
|
||||||
|
}
|
||||||
|
|
||||||
// We're done, empty the queue
|
// We're done, empty the queue
|
||||||
$this->empty_queue();
|
$this->empty_queue();
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
namespace phpbb\template\twig;
|
namespace phpbb\template\twig;
|
||||||
|
|
||||||
use Twig\Error\RuntimeError;
|
use Twig\Error\RuntimeError;
|
||||||
|
use Twig\Extension\CoreExtension;
|
||||||
|
use Twig\Runtime\EscaperRuntime;
|
||||||
|
|
||||||
class extension extends \Twig\Extension\AbstractExtension
|
class extension extends \Twig\Extension\AbstractExtension
|
||||||
{
|
{
|
||||||
|
@ -164,7 +166,7 @@ class extension extends \Twig\Extension\AbstractExtension
|
||||||
// We always include the last element (this was the past design)
|
// We always include the last element (this was the past design)
|
||||||
$end = ($end == -1 || $end === null) ? null : $end + 1;
|
$end = ($end == -1 || $end === null) ? null : $end + 1;
|
||||||
|
|
||||||
return twig_slice($env, $item, $start, $end, $preserveKeys);
|
return CoreExtension::slice($env->getCharset(), $item, $start, $end, $preserveKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -213,7 +215,7 @@ class extension extends \Twig\Extension\AbstractExtension
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
|
||||||
return twig_escape_filter($this->environment, call_user_func_array([$this, 'lang'], $args), 'js');
|
return $this->environment->getRuntime(EscaperRuntime::class)->escape(call_user_func_array([$this, 'lang'], $args), 'js');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,6 +25,7 @@ use phpbb\passwords\manager;
|
||||||
use phpbb\request\request;
|
use phpbb\request\request;
|
||||||
use phpbb\template\template;
|
use phpbb\template\template;
|
||||||
use phpbb\user;
|
use phpbb\user;
|
||||||
|
use phpbb\messenger\method\email;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,6 +51,9 @@ class reset_password
|
||||||
/** @var log_interface */
|
/** @var log_interface */
|
||||||
protected $log;
|
protected $log;
|
||||||
|
|
||||||
|
/** @var email */
|
||||||
|
protected $email_method;
|
||||||
|
|
||||||
/** @var manager */
|
/** @var manager */
|
||||||
protected $passwords_manager;
|
protected $passwords_manager;
|
||||||
|
|
||||||
|
@ -80,6 +84,7 @@ class reset_password
|
||||||
* @param helper $helper
|
* @param helper $helper
|
||||||
* @param language $language
|
* @param language $language
|
||||||
* @param log_interface $log
|
* @param log_interface $log
|
||||||
|
* @param email $email_method
|
||||||
* @param manager $passwords_manager
|
* @param manager $passwords_manager
|
||||||
* @param request $request
|
* @param request $request
|
||||||
* @param template $template
|
* @param template $template
|
||||||
|
@ -89,7 +94,7 @@ class reset_password
|
||||||
* @param string $php_ext
|
* @param string $php_ext
|
||||||
*/
|
*/
|
||||||
public function __construct(config $config, driver_interface $db, dispatcher $dispatcher, helper $helper,
|
public function __construct(config $config, driver_interface $db, dispatcher $dispatcher, helper $helper,
|
||||||
language $language, log_interface $log, manager $passwords_manager,
|
language $language, log_interface $log, email $email_method, manager $passwords_manager,
|
||||||
request $request, template $template, user $user, string $users_table,
|
request $request, template $template, user $user, string $users_table,
|
||||||
string $root_path, string $php_ext)
|
string $root_path, string $php_ext)
|
||||||
{
|
{
|
||||||
|
@ -99,6 +104,7 @@ class reset_password
|
||||||
$this->helper = $helper;
|
$this->helper = $helper;
|
||||||
$this->language = $language;
|
$this->language = $language;
|
||||||
$this->log = $log;
|
$this->log = $log;
|
||||||
|
$this->email_method = $email_method;
|
||||||
$this->passwords_manager = $passwords_manager;
|
$this->passwords_manager = $passwords_manager;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
|
@ -250,29 +256,18 @@ class reset_password
|
||||||
WHERE user_id = ' . $user_row['user_id'];
|
WHERE user_id = ' . $user_row['user_id'];
|
||||||
$this->db->sql_query($sql);
|
$this->db->sql_query($sql);
|
||||||
|
|
||||||
if (!class_exists('messenger'))
|
$this->email_method->set_use_queue(false);
|
||||||
{
|
$this->email_method->template('user_forgot_password', $user_row['user_lang']);
|
||||||
include($this->root_path . 'includes/functions_messenger.' . $this->php_ext);
|
$this->email_method->set_addresses($user_row);
|
||||||
}
|
$this->email_method->anti_abuse_headers($this->config, $this->user);
|
||||||
|
$this->email_method->assign_vars([
|
||||||
/** @var \messenger $messenger */
|
|
||||||
$messenger = new \messenger(false);
|
|
||||||
|
|
||||||
$messenger->template('user_forgot_password', $user_row['user_lang']);
|
|
||||||
|
|
||||||
$messenger->set_addresses($user_row);
|
|
||||||
|
|
||||||
$messenger->anti_abuse_headers($this->config, $this->user);
|
|
||||||
|
|
||||||
$messenger->assign_vars([
|
|
||||||
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT),
|
||||||
'U_RESET_PASSWORD' => generate_board_url(true) . $this->helper->route('phpbb_ucp_reset_password_controller', [
|
'U_RESET_PASSWORD' => generate_board_url(true) . $this->helper->route('phpbb_ucp_reset_password_controller', [
|
||||||
'u' => $user_row['user_id'],
|
'u' => $user_row['user_id'],
|
||||||
'token' => $reset_token,
|
'token' => $reset_token,
|
||||||
], false)
|
], false)
|
||||||
]);
|
]);
|
||||||
|
$this->email_method->send();
|
||||||
$messenger->send($user_row['user_notify_type']);
|
|
||||||
|
|
||||||
return $this->helper->message($message);
|
return $this->helper->message($message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ class phpbb_console_user_activate_test extends phpbb_console_user_base
|
||||||
$this->config,
|
$this->config,
|
||||||
$this->language,
|
$this->language,
|
||||||
$this->log,
|
$this->log,
|
||||||
|
$this->email,
|
||||||
$this->notifications,
|
$this->notifications,
|
||||||
$this->user_loader,
|
$this->user_loader,
|
||||||
$this->phpbb_root_path,
|
$this->phpbb_root_path,
|
||||||
|
|
|
@ -30,6 +30,7 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
|
||||||
$this->db,
|
$this->db,
|
||||||
$this->config,
|
$this->config,
|
||||||
$this->language,
|
$this->language,
|
||||||
|
$this->email,
|
||||||
$this->passwords_manager,
|
$this->passwords_manager,
|
||||||
$this->phpbb_root_path,
|
$this->phpbb_root_path,
|
||||||
$this->php_ext
|
$this->php_ext
|
||||||
|
|
|
@ -34,7 +34,7 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
|
||||||
{
|
{
|
||||||
global $auth, $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx;
|
global $auth, $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
$phpbb_dispatcher = new \phpbb\event\dispatcher();
|
||||||
$phpbb_container = new phpbb_mock_container_builder();
|
$phpbb_container = new phpbb_mock_container_builder();
|
||||||
$phpbb_container->set('cache.driver', new phpbb_mock_cache());
|
$phpbb_container->set('cache.driver', new phpbb_mock_cache());
|
||||||
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
|
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
|
||||||
|
@ -105,6 +105,120 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
|
||||||
|
|
||||||
$phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
|
$phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
|
||||||
|
|
||||||
|
$assets_bag = new \phpbb\template\assets_bag();
|
||||||
|
$phpbb_container->set('assets.bag', $assets_bag);
|
||||||
|
|
||||||
|
$phpbb_container->set('dispatcher', $phpbb_dispatcher);
|
||||||
|
|
||||||
|
$core_cache_dir = $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/';
|
||||||
|
$phpbb_container->setParameter('core.cache_dir', $core_cache_dir);
|
||||||
|
|
||||||
|
$core_messenger_queue_file = $core_cache_dir . 'queue.' . $phpEx;
|
||||||
|
$phpbb_container->setParameter('core.messenger_queue_file', $core_messenger_queue_file);
|
||||||
|
|
||||||
|
$messenger_method_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||||
|
$messenger_method_collection->add('messenger.method.email');
|
||||||
|
$phpbb_container->set('messenger.method_collection', $messenger_method_collection);
|
||||||
|
|
||||||
|
$messenger_queue = new \phpbb\messenger\queue($config, $phpbb_dispatcher, $messenger_method_collection, $core_messenger_queue_file);
|
||||||
|
$phpbb_container->set('messenger.queue', $messenger_queue);
|
||||||
|
|
||||||
|
$request = new phpbb_mock_request;
|
||||||
|
$phpbb_container->set('request', $request);
|
||||||
|
|
||||||
|
$symfony_request = new \phpbb\symfony_request(
|
||||||
|
$request
|
||||||
|
);
|
||||||
|
|
||||||
|
$phpbb_path_helper = new \phpbb\path_helper(
|
||||||
|
$symfony_request,
|
||||||
|
$request,
|
||||||
|
$phpbb_root_path,
|
||||||
|
$phpEx
|
||||||
|
);
|
||||||
|
$phpbb_container->set('path_helper', $phpbb_path_helper);
|
||||||
|
|
||||||
|
$factory = new \phpbb\db\tools\factory();
|
||||||
|
$db_doctrine = $this->new_doctrine_dbal();
|
||||||
|
$db_tools = $factory->get($db_doctrine);
|
||||||
|
$migrator = new \phpbb\db\migrator(
|
||||||
|
$phpbb_container,
|
||||||
|
$config,
|
||||||
|
$db,
|
||||||
|
$db_tools,
|
||||||
|
'phpbb_migrations',
|
||||||
|
$phpbb_root_path,
|
||||||
|
$this->php_ext,
|
||||||
|
'phpbb_',
|
||||||
|
self::get_core_tables(),
|
||||||
|
[],
|
||||||
|
new \phpbb\db\migration\helper()
|
||||||
|
);
|
||||||
|
$phpbb_container->set('migrator', $migrator);
|
||||||
|
|
||||||
|
$finder_factory = new \phpbb\finder\factory(null, false, $phpbb_root_path, $this->php_ext);
|
||||||
|
$extension_manager = new \phpbb\extension\manager(
|
||||||
|
$phpbb_container,
|
||||||
|
$db,
|
||||||
|
$config,
|
||||||
|
$finder_factory,
|
||||||
|
'phpbb_ext',
|
||||||
|
__DIR__ . '/',
|
||||||
|
new \phpbb\cache\service(new phpbb_mock_cache(), $config, $db, $phpbb_dispatcher, $phpbb_root_path, $this->php_ext)
|
||||||
|
);
|
||||||
|
$phpbb_container->set('ext.manager', $extension_manager);
|
||||||
|
|
||||||
|
$context = new \phpbb\template\context();
|
||||||
|
$cache_path = $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/twig';
|
||||||
|
$phpbb_container->setParameter('core.template.cache_path', $cache_path);
|
||||||
|
$filesystem = new \phpbb\filesystem\filesystem();
|
||||||
|
$phpbb_container->set('filesystem', $filesystem);
|
||||||
|
|
||||||
|
$twig = new \phpbb\template\twig\environment(
|
||||||
|
$assets_bag,
|
||||||
|
$this->config,
|
||||||
|
$filesystem,
|
||||||
|
$phpbb_path_helper,
|
||||||
|
$cache_path,
|
||||||
|
null,
|
||||||
|
new \phpbb\template\twig\loader(''),
|
||||||
|
$phpbb_dispatcher,
|
||||||
|
[
|
||||||
|
'cache' => false,
|
||||||
|
'debug' => false,
|
||||||
|
'auto_reload' => true,
|
||||||
|
'autoescape' => false,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $this->language);
|
||||||
|
$phpbb_container->set('template.twig.extensions.phpbb', $twig_extension);
|
||||||
|
|
||||||
|
$twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||||
|
$twig_extensions_collection->add('template.twig.extensions.phpbb');
|
||||||
|
$phpbb_container->set('template.twig.extensions.collection', $twig_extensions_collection);
|
||||||
|
|
||||||
|
$twig->addExtension($twig_extension);
|
||||||
|
$twig_lexer = new \phpbb\template\twig\lexer($twig);
|
||||||
|
$phpbb_container->set('template.twig.lexer', $twig_lexer);
|
||||||
|
|
||||||
|
$this->email = new \phpbb\messenger\method\email(
|
||||||
|
$assets_bag,
|
||||||
|
$this->config,
|
||||||
|
$phpbb_dispatcher,
|
||||||
|
$this->language,
|
||||||
|
$messenger_queue,
|
||||||
|
$phpbb_path_helper,
|
||||||
|
$request,
|
||||||
|
$twig_extensions_collection,
|
||||||
|
$twig_lexer,
|
||||||
|
$user,
|
||||||
|
$phpbb_root_path,
|
||||||
|
$cache_path,
|
||||||
|
$extension_manager,
|
||||||
|
$this->log
|
||||||
|
);
|
||||||
|
$phpbb_container->set('messenger.method.email', $this->email);
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
$phpbb_container->set('assets.bag', $assets_bag);
|
$phpbb_container->set('assets.bag', $assets_bag);
|
||||||
|
|
||||||
$context = new \phpbb\template\context();
|
$context = new \phpbb\template\context();
|
||||||
|
$dispatcher = new \phpbb\event\dispatcher();
|
||||||
$twig = new \phpbb\template\twig\environment(
|
$twig = new \phpbb\template\twig\environment(
|
||||||
$assets_bag,
|
$assets_bag,
|
||||||
$config,
|
$config,
|
||||||
|
@ -78,7 +79,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
$cache_path,
|
$cache_path,
|
||||||
null,
|
null,
|
||||||
new \phpbb\template\twig\loader(''),
|
new \phpbb\template\twig\loader(''),
|
||||||
new \phpbb\event\dispatcher(),
|
$dispatcher,
|
||||||
array(
|
array(
|
||||||
'cache' => false,
|
'cache' => false,
|
||||||
'debug' => false,
|
'debug' => false,
|
||||||
|
@ -94,16 +95,53 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
$phpbb_container->set('template.twig.extensions.collection', $twig_extensions_collection);
|
$phpbb_container->set('template.twig.extensions.collection', $twig_extensions_collection);
|
||||||
|
|
||||||
$twig->addExtension($twig_extension);
|
$twig->addExtension($twig_extension);
|
||||||
$phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
|
$twig_lexer = new \phpbb\template\twig\lexer($twig);
|
||||||
|
$phpbb_container->set('template.twig.lexer', $twig_lexer);
|
||||||
|
$phpbb_container->set('dispatcher', $dispatcher);
|
||||||
|
$phpbb_container->set('language', $lang);
|
||||||
|
$phpbb_container->set('request', $request);
|
||||||
|
|
||||||
if (!class_exists('messenger'))
|
$db = $this->getMockBuilder('\phpbb\db\driver\mysqli')
|
||||||
{
|
->disableOriginalConstructor()
|
||||||
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
->getMock();
|
||||||
}
|
$auth = $this->createMock('\phpbb\auth\auth');
|
||||||
|
$log = new \phpbb\log\log($db, $user, $auth, $dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
|
||||||
|
$phpbb_container->set('log', $log);
|
||||||
|
$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
|
||||||
|
$phpbb_container->setParameter('core.php_ext', $phpEx);
|
||||||
|
|
||||||
$this->messenger = new \messenger();
|
$core_cache_dir = $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/';
|
||||||
|
$phpbb_container->setParameter('core.cache_dir', $core_cache_dir);
|
||||||
|
|
||||||
$reflection = new ReflectionObject($this->messenger);
|
$core_messenger_queue_file = $core_cache_dir . 'queue.' . $phpEx;
|
||||||
|
$phpbb_container->setParameter('core.messenger_queue_file', $core_messenger_queue_file);
|
||||||
|
|
||||||
|
$messenger_method_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||||
|
$messenger_method_collection->add('messenger.method.email');
|
||||||
|
$phpbb_container->set('messenger.method_collection', $messenger_method_collection);
|
||||||
|
|
||||||
|
$messenger_queue = new \phpbb\messenger\queue($config, $dispatcher, $messenger_method_collection, $core_messenger_queue_file);
|
||||||
|
$phpbb_container->set('messenger.queue', $messenger_queue);
|
||||||
|
|
||||||
|
$this->email = new \phpbb\messenger\method\email(
|
||||||
|
$assets_bag,
|
||||||
|
$config,
|
||||||
|
$dispatcher,
|
||||||
|
$lang,
|
||||||
|
$messenger_queue,
|
||||||
|
$phpbb_path_helper,
|
||||||
|
$request,
|
||||||
|
$twig_extensions_collection,
|
||||||
|
$twig_lexer,
|
||||||
|
$user,
|
||||||
|
$phpbb_root_path,
|
||||||
|
$cache_path,
|
||||||
|
$extension_manager,
|
||||||
|
$log
|
||||||
|
);
|
||||||
|
$phpbb_container->set('messenger.method.email', $this->email);
|
||||||
|
|
||||||
|
$reflection = new ReflectionObject($this->email);
|
||||||
$this->reflection_template_property = $reflection->getProperty('template');
|
$this->reflection_template_property = $reflection->getProperty('template');
|
||||||
$this->reflection_template_property->setAccessible(true);
|
$this->reflection_template_property->setAccessible(true);
|
||||||
}
|
}
|
||||||
|
@ -123,9 +161,9 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
global $config, $phpEx, $user;
|
global $config, $phpEx, $user;
|
||||||
|
|
||||||
$this->messenger->set_addresses($user->data);
|
$this->email->set_addresses($user->data);
|
||||||
|
|
||||||
$this->messenger->assign_vars(array(
|
$this->email->assign_vars(array(
|
||||||
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . html_entity_decode($config['board_email_sig'], ENT_COMPAT)),
|
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . html_entity_decode($config['board_email_sig'], ENT_COMPAT)),
|
||||||
'SITENAME' => html_entity_decode($config['sitename'], ENT_COMPAT),
|
'SITENAME' => html_entity_decode($config['sitename'], ENT_COMPAT),
|
||||||
|
|
||||||
|
@ -137,9 +175,9 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
'U_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?f=1",
|
'U_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?f=1",
|
||||||
'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?uid=2&f=1&unwatch=forum",
|
'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?uid=2&f=1&unwatch=forum",
|
||||||
));
|
));
|
||||||
$this->messenger->template('newtopic_notify', $user->data['user_lang'], '', '');
|
$this->email->template('newtopic_notify', $user->data['user_lang'], '', '');
|
||||||
|
|
||||||
$reflection_template = $this->reflection_template_property->getValue($this->messenger);
|
$reflection_template = $this->reflection_template_property->getValue($this->email);
|
||||||
$msg = trim($reflection_template->assign_display('body'));
|
$msg = trim($reflection_template->assign_display('body'));
|
||||||
|
|
||||||
$this->assertStringContainsString($author_name, $msg);
|
$this->assertStringContainsString($author_name, $msg);
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* This file is part of the phpBB Forum Software package.
|
|
||||||
*
|
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
|
||||||
*
|
|
||||||
* For full copyright and license information, please see
|
|
||||||
* the docs/CREDITS.txt file.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class phpbb_headers_encoding_test extends phpbb_test_case
|
|
||||||
{
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
global $phpbb_root_path, $phpEx;
|
|
||||||
|
|
||||||
if (!function_exists('mail_encode'))
|
|
||||||
{
|
|
||||||
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function headers_encoding_data()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['test@yourdomain.com <phpBB fake test email>', 'Q', 'US-ASCII'],
|
|
||||||
['test@yourdomain.com <Несуществующий почтовый адрес phpBB>', 'B', 'UTF-8'],
|
|
||||||
["\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88", 'B', 'UTF-8'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider headers_encoding_data
|
|
||||||
*/
|
|
||||||
public function test_headers_encoding($header, $scheme, $encoding)
|
|
||||||
{
|
|
||||||
$encoded_string = mail_encode($header);
|
|
||||||
$this->assertStringStartsWith("=?$encoding?$scheme?", $encoded_string);
|
|
||||||
$this->assertStringEndsWith('?=', $encoded_string);
|
|
||||||
|
|
||||||
// Result of iconv_mime_decode() on decoded header should be equal to initial header
|
|
||||||
$decoded_string = iconv_mime_decode($encoded_string, 0, $encoding);
|
|
||||||
$this->assertEquals(0, strcmp($header, $decoded_string));
|
|
||||||
}
|
|
||||||
}
|
|
65
tests/functional/acp_test.php
Normal file
65
tests/functional/acp_test.php
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group functional
|
||||||
|
*/
|
||||||
|
class phpbb_functional_acp_test extends phpbb_functional_test_case
|
||||||
|
{
|
||||||
|
public function test_all_acp_module_links()
|
||||||
|
{
|
||||||
|
$this->login();
|
||||||
|
$this->admin_login();
|
||||||
|
$this->add_lang(['common']);
|
||||||
|
|
||||||
|
// Browse ACP main page
|
||||||
|
$crawler = self::request('GET', 'index.php');
|
||||||
|
$crawler = self::$client->click($crawler->selectLink($this->lang('ACP_SHORT'))->link());
|
||||||
|
self::assert_response_html();
|
||||||
|
|
||||||
|
// Get all ACP module URLs array
|
||||||
|
$acp_modules = $crawler->filter('li.tab a')->each(
|
||||||
|
function ($node, $i)
|
||||||
|
{
|
||||||
|
// Filter out responsive mode links
|
||||||
|
if (empty($node->attr('class')))
|
||||||
|
{
|
||||||
|
return $node->link();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$this->assertNotEmpty($acp_modules);
|
||||||
|
|
||||||
|
// Browse all ACP modules and get their mode URLs array
|
||||||
|
$acp_submodules = [];
|
||||||
|
foreach ($acp_modules as $module)
|
||||||
|
{
|
||||||
|
$crawler = self::$client->click($module);
|
||||||
|
self::assert_response_html();
|
||||||
|
$acp_submodules = array_merge($acp_submodules, $crawler->filter('div.menu-block li a')->each(
|
||||||
|
function ($node, $i)
|
||||||
|
{
|
||||||
|
return $node->link();
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
$this->assertNotEmpty($acp_submodules);
|
||||||
|
|
||||||
|
// Browse all ACP submodules' modes
|
||||||
|
foreach ($acp_submodules as $acp_submodule)
|
||||||
|
{
|
||||||
|
self::$client->click($acp_submodule);
|
||||||
|
self::assert_response_html();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case
|
||||||
// Browse MCP main page
|
// Browse MCP main page
|
||||||
$crawler = self::request('GET', 'index.php');
|
$crawler = self::request('GET', 'index.php');
|
||||||
$crawler = self::$client->click($crawler->selectLink($this->lang('MCP_SHORT'))->link());
|
$crawler = self::$client->click($crawler->selectLink($this->lang('MCP_SHORT'))->link());
|
||||||
|
self::assert_response_html();
|
||||||
|
|
||||||
// Get all MCP module URLs array
|
// Get all MCP module URLs array
|
||||||
$mcp_modules = $crawler->filter('.tabs a')->each(
|
$mcp_modules = $crawler->filter('.tabs a')->each(
|
||||||
|
@ -32,12 +33,14 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case
|
||||||
return $node->link();
|
return $node->link();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
$this->assertNotEmpty($mcp_modules);
|
||||||
|
|
||||||
// Browse all MCP modules and get their mode URLs array
|
// Browse all MCP modules and get their mode URLs array
|
||||||
$mcp_submodules = [];
|
$mcp_submodules = [];
|
||||||
foreach ($mcp_modules as $module)
|
foreach ($mcp_modules as $module)
|
||||||
{
|
{
|
||||||
$crawler = self::$client->click($module);
|
$crawler = self::$client->click($module);
|
||||||
|
self::assert_response_html();
|
||||||
$mcp_submodules = array_merge($mcp_submodules, $crawler->filter('.cp-menu a')->each(
|
$mcp_submodules = array_merge($mcp_submodules, $crawler->filter('.cp-menu a')->each(
|
||||||
function ($node, $i)
|
function ($node, $i)
|
||||||
{
|
{
|
||||||
|
@ -45,11 +48,13 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
$this->assertNotEmpty($mcp_submodules);
|
||||||
|
|
||||||
// Browse all MCP submodules' modes
|
// Browse all MCP submodules' modes
|
||||||
foreach ($mcp_submodules as $mcp_submodule)
|
foreach ($mcp_submodules as $mcp_submodule)
|
||||||
{
|
{
|
||||||
self::$client->click($mcp_submodule);
|
self::$client->click($mcp_submodule);
|
||||||
|
self::assert_response_html();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,11 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
|
||||||
|
|
||||||
$phpbb_container->addCompilerPass(new phpbb\di\pass\markpublic_pass());
|
$phpbb_container->addCompilerPass(new phpbb\di\pass\markpublic_pass());
|
||||||
|
|
||||||
|
$messenger_method_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||||
|
$messenger_method_collection->add('messenger.method.email');
|
||||||
|
$messenger_method_collection->add('messenger.method.jabber');
|
||||||
|
$phpbb_container->set('messenger.method_collection', $messenger_method_collection);
|
||||||
|
|
||||||
$phpbb_container->compile();
|
$phpbb_container->compile();
|
||||||
|
|
||||||
$this->notifications->setDependencies($this->auth, $this->config);
|
$this->notifications->setDependencies($this->auth, $this->config);
|
||||||
|
|
|
@ -105,6 +105,11 @@ class notification_method_email_test extends phpbb_tests_notification_base
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$messenger_method_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||||
|
$messenger_method_collection->add('messenger.method.email');
|
||||||
|
$messenger_method_collection->add('messenger.method.jabber');
|
||||||
|
$phpbb_container->set('messenger.method_collection', $messenger_method_collection);
|
||||||
|
|
||||||
$this->notification_method_email = $this->getMockBuilder('\phpbb\notification\method\email')
|
$this->notification_method_email = $this->getMockBuilder('\phpbb\notification\method\email')
|
||||||
->setConstructorArgs([
|
->setConstructorArgs([
|
||||||
$phpbb_container->get('user_loader'),
|
$phpbb_container->get('user_loader'),
|
||||||
|
@ -113,7 +118,8 @@ class notification_method_email_test extends phpbb_tests_notification_base
|
||||||
$phpbb_container->get('dbal.conn'),
|
$phpbb_container->get('dbal.conn'),
|
||||||
$phpbb_root_path,
|
$phpbb_root_path,
|
||||||
$phpEx,
|
$phpEx,
|
||||||
$phpbb_container->getParameter('tables.notification_emails')
|
$phpbb_container->getParameter('tables.notification_emails'),
|
||||||
|
$phpbb_container->get('messenger.method_collection')
|
||||||
])
|
])
|
||||||
->setMethods(['notify_using_messenger'])
|
->setMethods(['notify_using_messenger'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
|
@ -171,6 +171,9 @@ class notification_method_webpush_test extends phpbb_tests_notification_base
|
||||||
$ban_manager = new \phpbb\ban\manager($collection, new \phpbb\cache\driver\dummy(), $this->db, $this->language, $this->log, $user, 'phpbb_bans', 'phpbb_users');
|
$ban_manager = new \phpbb\ban\manager($collection, new \phpbb\cache\driver\dummy(), $this->db, $this->language, $this->log, $user, 'phpbb_bans', 'phpbb_users');
|
||||||
$phpbb_container->set('ban.manager', $ban_manager);
|
$phpbb_container->set('ban.manager', $ban_manager);
|
||||||
|
|
||||||
|
$messenger_method_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||||
|
$phpbb_container->set('messenger.method_collection', $messenger_method_collection);
|
||||||
|
|
||||||
$this->notification_method_webpush = new \phpbb\notification\method\webpush(
|
$this->notification_method_webpush = new \phpbb\notification\method\webpush(
|
||||||
$phpbb_container->get('config'),
|
$phpbb_container->get('config'),
|
||||||
$phpbb_container->get('dbal.conn'),
|
$phpbb_container->get('dbal.conn'),
|
||||||
|
|
|
@ -158,6 +158,12 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
|
||||||
$phpbb_container->setParameter('tables.notification_push', 'phpbb_notification_push');
|
$phpbb_container->setParameter('tables.notification_push', 'phpbb_notification_push');
|
||||||
$phpbb_container->setParameter('tables.push_subscriptions', 'phpbb_push_subscriptions');
|
$phpbb_container->setParameter('tables.push_subscriptions', 'phpbb_push_subscriptions');
|
||||||
$phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
|
$phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
|
||||||
|
|
||||||
|
$messenger_method_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||||
|
$messenger_method_collection->add('messenger.method.email');
|
||||||
|
$messenger_method_collection->add('messenger.method.jabber');
|
||||||
|
$phpbb_container->set('messenger.method_collection', $messenger_method_collection);
|
||||||
|
|
||||||
$phpbb_container->addCompilerPass(new phpbb\di\pass\markpublic_pass());
|
$phpbb_container->addCompilerPass(new phpbb\di\pass\markpublic_pass());
|
||||||
$phpbb_container->compile();
|
$phpbb_container->compile();
|
||||||
|
|
||||||
|
|
|
@ -324,6 +324,123 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
return $extension_manager;
|
return $extension_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function get_messenger_method_email($container)
|
||||||
|
{
|
||||||
|
global $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
|
$config = new \phpbb\config\config(
|
||||||
|
[
|
||||||
|
'version' => PHPBB_VERSION,
|
||||||
|
'email_enable' => false,
|
||||||
|
'email_package_size' => 0,
|
||||||
|
'smtp_delivery' => 0,
|
||||||
|
'default_lang' => 'en',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||||
|
$lang = new \phpbb\language\language($lang_loader);
|
||||||
|
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||||
|
$container->set('user', $user);
|
||||||
|
$container->set('language', $lang);
|
||||||
|
|
||||||
|
$assets_bag = new \phpbb\template\assets_bag();
|
||||||
|
$container->set('assets.bag', $assets_bag);
|
||||||
|
|
||||||
|
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||||
|
$container->set('dispatcher', $phpbb_dispatcher);
|
||||||
|
|
||||||
|
$core_cache_dir = $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/';
|
||||||
|
$container->setParameter('core.cache_dir', $core_cache_dir);
|
||||||
|
|
||||||
|
$core_messenger_queue_file = $core_cache_dir . 'queue.' . $phpEx;
|
||||||
|
$container->setParameter('core.messenger_queue_file', $core_messenger_queue_file);
|
||||||
|
|
||||||
|
$messenger_method_collection = new \phpbb\di\service_collection($container);
|
||||||
|
$messenger_method_collection->add('messenger.method.email');
|
||||||
|
$container->set('messenger.method_collection', $messenger_method_collection);
|
||||||
|
|
||||||
|
$messenger_queue = new \phpbb\messenger\queue($config, $phpbb_dispatcher, $messenger_method_collection, $core_messenger_queue_file);
|
||||||
|
$container->set('messenger.queue', $messenger_queue);
|
||||||
|
|
||||||
|
$request = new phpbb_mock_request;
|
||||||
|
$container->set('request', $request);
|
||||||
|
|
||||||
|
$symfony_request = new \phpbb\symfony_request(
|
||||||
|
$request
|
||||||
|
);
|
||||||
|
|
||||||
|
$phpbb_path_helper = new \phpbb\path_helper(
|
||||||
|
$symfony_request,
|
||||||
|
$request,
|
||||||
|
$phpbb_root_path,
|
||||||
|
$phpEx
|
||||||
|
);
|
||||||
|
$container->set('path_helper', $phpbb_path_helper);
|
||||||
|
|
||||||
|
$dbms = self::$config['dbms'];
|
||||||
|
$db = new $dbms();
|
||||||
|
$db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']);
|
||||||
|
|
||||||
|
$extension_manager = new phpbb_mock_extension_manager($phpbb_root_path, [], $container);
|
||||||
|
$container->set('ext.manager', $extension_manager);
|
||||||
|
|
||||||
|
$context = new \phpbb\template\context();
|
||||||
|
$cache_path = $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/twig';
|
||||||
|
$container->setParameter('core.template.cache_path', $cache_path);
|
||||||
|
$filesystem = new \phpbb\filesystem\filesystem();
|
||||||
|
$container->set('filesystem', $filesystem);
|
||||||
|
|
||||||
|
$twig = new \phpbb\template\twig\environment(
|
||||||
|
$assets_bag,
|
||||||
|
$config,
|
||||||
|
$filesystem,
|
||||||
|
$phpbb_path_helper,
|
||||||
|
$cache_path,
|
||||||
|
null,
|
||||||
|
new \phpbb\template\twig\loader(''),
|
||||||
|
$phpbb_dispatcher,
|
||||||
|
[
|
||||||
|
'cache' => false,
|
||||||
|
'debug' => false,
|
||||||
|
'auto_reload' => true,
|
||||||
|
'autoescape' => false,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $lang);
|
||||||
|
$container->set('template.twig.extensions.phpbb', $twig_extension);
|
||||||
|
|
||||||
|
$twig_extensions_collection = new \phpbb\di\service_collection($container);
|
||||||
|
$twig_extensions_collection->add('template.twig.extensions.phpbb');
|
||||||
|
$container->set('template.twig.extensions.collection', $twig_extensions_collection);
|
||||||
|
|
||||||
|
$twig->addExtension($twig_extension);
|
||||||
|
$twig_lexer = new \phpbb\template\twig\lexer($twig);
|
||||||
|
$container->set('template.twig.lexer', $twig_lexer);
|
||||||
|
|
||||||
|
$auth = new \phpbb\auth\auth();
|
||||||
|
$log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
|
||||||
|
$container->set('log', $log);
|
||||||
|
|
||||||
|
$email_method = new \phpbb\messenger\method\email(
|
||||||
|
$assets_bag,
|
||||||
|
$config,
|
||||||
|
$phpbb_dispatcher,
|
||||||
|
$lang,
|
||||||
|
$messenger_queue,
|
||||||
|
$phpbb_path_helper,
|
||||||
|
$request,
|
||||||
|
$twig_extensions_collection,
|
||||||
|
$twig_lexer,
|
||||||
|
$user,
|
||||||
|
$phpbb_root_path,
|
||||||
|
$cache_path,
|
||||||
|
$extension_manager,
|
||||||
|
$log
|
||||||
|
);
|
||||||
|
$container->set('messenger.method.email', $email_method);
|
||||||
|
}
|
||||||
|
|
||||||
protected static function install_board()
|
protected static function install_board()
|
||||||
{
|
{
|
||||||
global $phpbb_root_path, $phpEx;
|
global $phpbb_root_path, $phpEx;
|
||||||
|
@ -374,6 +491,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
$container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task());
|
$container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task());
|
||||||
$container->register('installer.install_finish.install_extensions')->setSynthetic(true);
|
$container->register('installer.install_finish.install_extensions')->setSynthetic(true);
|
||||||
$container->set('installer.install_finish.install_extensions', new phpbb_mock_null_installer_task());
|
$container->set('installer.install_finish.install_extensions', new phpbb_mock_null_installer_task());
|
||||||
|
self::get_messenger_method_email($container);
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
$language = $container->get('language');
|
$language = $container->get('language');
|
||||||
|
@ -418,8 +536,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
|
|
||||||
$iohandler->set_input('email_enable', true);
|
$iohandler->set_input('email_enable', true);
|
||||||
$iohandler->set_input('smtp_delivery', '1');
|
$iohandler->set_input('smtp_delivery', '1');
|
||||||
$iohandler->set_input('smtp_host', 'nxdomain.phpbb.com');
|
$iohandler->set_input('smtp_host', '');
|
||||||
$iohandler->set_input('smtp_auth', 'PLAIN');
|
|
||||||
$iohandler->set_input('smtp_user', 'nxuser');
|
$iohandler->set_input('smtp_user', 'nxuser');
|
||||||
$iohandler->set_input('smtp_pass', 'nxpass');
|
$iohandler->set_input('smtp_pass', 'nxpass');
|
||||||
$iohandler->set_input('submit_email', 'submit');
|
$iohandler->set_input('submit_email', 'submit');
|
||||||
|
|
|
@ -38,7 +38,6 @@ installer:
|
||||||
enabled: false
|
enabled: false
|
||||||
smtp_delivery : ~
|
smtp_delivery : ~
|
||||||
smtp_host: ~
|
smtp_host: ~
|
||||||
smtp_auth: ~
|
|
||||||
smtp_user: ~
|
smtp_user: ~
|
||||||
smtp_pass: ~
|
smtp_pass: ~
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue