aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Senko <jakubsenko@gmail.com>2019-02-18 16:04:27 +0100
committerJakub Senko <jakubsenko@gmail.com>2019-02-27 10:32:11 +0100
commit8c29ef31886d6884ee3b4858476ae5ee1eb19a17 (patch)
treee5018faa3c2af4b9b3234df22533a0ff1058d54d
parent33afd3f350b60bd60581e7e0292381619da96df2 (diff)
downloadforums-8c29ef31886d6884ee3b4858476ae5ee1eb19a17.tar
forums-8c29ef31886d6884ee3b4858476ae5ee1eb19a17.tar.gz
forums-8c29ef31886d6884ee3b4858476ae5ee1eb19a17.tar.bz2
forums-8c29ef31886d6884ee3b4858476ae5ee1eb19a17.tar.xz
forums-8c29ef31886d6884ee3b4858476ae5ee1eb19a17.zip
[ticket/15970] Add core.message_admin_form_submit_before
PHPBB3-15970
-rw-r--r--phpBB/config/default/container/services_content.yml1
-rw-r--r--phpBB/phpbb/message/admin_form.php29
2 files changed, 29 insertions, 1 deletions
diff --git a/phpBB/config/default/container/services_content.yml b/phpBB/config/default/container/services_content.yml
index 602fd25f4e..6717c20337 100644
--- a/phpBB/config/default/container/services_content.yml
+++ b/phpBB/config/default/container/services_content.yml
@@ -35,6 +35,7 @@ services:
- '@config_text'
- '@dbal.conn'
- '@user'
+ - '@dispatcher'
- '%core.root_path%'
- '%core.php_ext%'
diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php
index 96b8d3499e..5e772e523d 100644
--- a/phpBB/phpbb/message/admin_form.php
+++ b/phpBB/phpbb/message/admin_form.php
@@ -22,6 +22,9 @@ class admin_form extends form
/** @var \phpbb\config\db_text */
protected $config_text;
+ /** @var \phpbb\event\dispatcher_interface */
+ protected $dispatcher;
+
/** @var string */
protected $subject;
/** @var string */
@@ -37,13 +40,15 @@ class admin_form extends form
* @param \phpbb\config\db_text $config_text
* @param \phpbb\db\driver\driver_interface $db
* @param \phpbb\user $user
+ * @param \phpbb\event\dispatcher_interface $dispatcher
* @param string $phpbb_root_path
* @param string $phpEx
*/
- public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx)
+ public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\event\dispatcher_interface $dispatcher, $phpbb_root_path, $phpEx)
{
parent::__construct($auth, $config, $db, $user, $phpbb_root_path, $phpEx);
$this->config_text = $config_text;
+ $this->dispatcher = $dispatcher;
}
/**
@@ -91,6 +96,28 @@ class admin_form extends form
$this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL'];
}
+ $subject = $this->subject;
+ $body = $this->body;
+ $errors = $this->errors;
+ /**
+ * You can use this event to modify subject and/or body and add new errors.
+ *
+ * @event core.message_admin_form_submit_before
+ * @var string subject Message subject
+ * @var string body Message body
+ * @var array errors Form errors
+ * @since 3.2.6-RC1
+ */
+ $vars = [
+ 'subject',
+ 'body',
+ 'errors',
+ ];
+ extract($this->dispatcher->trigger_event('core.message_admin_form_submit_before', compact($vars)));
+ $this->subject = $subject;
+ $this->body = $body;
+ $this->errors = $errors;
+
if ($this->user->data['is_registered'])
{
$this->message->set_sender_from_user($this->user);