From fffb07fd91b42d64e71e16a13bcdde87114fad19 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 18:09:25 +0200 Subject: [ticket/10073] Use namespaces and fix all class names PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 112 +++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 phpBB/phpbb/message/admin_form.php (limited to 'phpBB/phpbb/message/admin_form.php') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php new file mode 100644 index 0000000000..dc995062a0 --- /dev/null +++ b/phpBB/phpbb/message/admin_form.php @@ -0,0 +1,112 @@ +config['contact_admin_form_enable']) /** TODO: && !$this->config['contact_admin_info']) */ + { + return 'NO_CONTACT_PAGE'; + } + + return false; + } + + public function bind(\phpbb\request\request_interface $request) + { + parent::bind($request); + + $this->subject = $request->variable('subject', '', true); + $this->sender_address = $request->variable('email', ''); + $this->sender_name = $request->variable('name', '', true); + } + + public function submit(\messenger $messenger) + { + if (!$this->subject) + { + $this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL']; + } + if (!$this->body) + { + $this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL']; + } + + if ($this->user->data['is_registered']) + { + $this->message->set_sender_from_user($this->user); + $this->sender_name = $this->user->data['username']; + $this->sender_address = $this->user->data['user_email']; + } + else + { + if (!$this->sender_name) + { + $this->errors[] = $this->user->lang['EMPTY_SENDER_NAME']; + } + if (!$this->sender_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->sender_address)) + { + $this->errors[] = $this->user->lang['EMPTY_SENDER_EMAIL']; + } + + $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_template('contact_admin'); + $this->message->set_subject($this->subject); + $this->message->set_body($this->body); + $this->message->add_recipient( + $this->user->lang['ADMINISTRATOR'], + $this->config['board_contact'], + $this->config['default_lang'], + NOTIFY_EMAIL + ); + + $this->message->set_template_vars(array( + 'FROM_EMAIL_ADDRESS' => $this->sender_address, + 'FROM_IP_ADDRESS' => $this->user->ip, + 'S_IS_REGISTERED' => $this->user->data['is_registered'], + + 'U_FROM_PROFILE' => generate_board_url() . '/memberlist.' . $this->phpEx . '?mode=viewprofile&u=' . $this->user->data['user_id'], + )); + + parent::submit($messenger); + } + + public function render(\phpbb\template\template $template) + { + $template->assign_vars(array( + 'S_CONTACT_ADMIN' => true, + 'S_CONTACT_FORM' => $this->config['contact_admin_form_enable'], + 'S_IS_REGISTERED' => $this->user->data['is_registered'], + + 'CONTACT_INFO' => '', /** TODO: $this->config['contact_admin_info'] */ + 'MESSAGE' => $this->body, + 'SUBJECT' => $this->subject, + 'NAME' => $this->sender_name, + 'EMAIL' => $this->sender_address, + )); + + parent::render($template); + } +} -- cgit v1.2.1 From 67cf0a912c8ed24c7466163fa409e8154082e1df Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 23:24:10 +0200 Subject: [ticket/10073] Add doc blocks to new classes PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'phpBB/phpbb/message/admin_form.php') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index dc995062a0..5201994c73 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -9,12 +9,24 @@ namespace phpbb\message; +/** +* Class admin_form +* Displays a message to the user and allows him to send an email +* +* @package phpbb\message +*/ class admin_form extends form { + /** @var string */ protected $subject; + /** @var string */ protected $sender_name; + /** @var string */ protected $sender_address; + /** + * {inheritDoc} + */ public function check_allow() { $error = parent::check_allow(); @@ -31,6 +43,9 @@ class admin_form extends form return false; } + /** + * {inheritDoc} + */ public function bind(\phpbb\request\request_interface $request) { parent::bind($request); @@ -40,6 +55,9 @@ class admin_form extends form $this->sender_name = $request->variable('name', '', true); } + /** + * {inheritDoc} + */ public function submit(\messenger $messenger) { if (!$this->subject) @@ -93,6 +111,9 @@ class admin_form extends form parent::submit($messenger); } + /** + * {inheritDoc} + */ public function render(\phpbb\template\template $template) { $template->assign_vars(array( -- cgit v1.2.1 From 35b88624f5f85e3d7ea048e9f537dc477bf913c6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 23:34:44 +0200 Subject: [ticket/10073] Remove unneccessary todos he config switch is enough PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/message/admin_form.php') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index 5201994c73..57564cff12 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -35,7 +35,7 @@ class admin_form extends form return $error; } - if (!$this->config['contact_admin_form_enable']) /** TODO: && !$this->config['contact_admin_info']) */ + if (!$this->config['contact_admin_form_enable']) { return 'NO_CONTACT_PAGE'; } -- cgit v1.2.1 From ef8d7b995e854c64a5f529978ee4898030ae9fa4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 23:46:28 +0200 Subject: [ticket/10073] Add @config_text to admin_form PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/message/admin_form.php') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index 57564cff12..f7eddb59dc 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -17,6 +17,9 @@ namespace phpbb\message; */ class admin_form extends form { + /** @var \phpbb\config\db_text */ + protected $config_text; + /** @var string */ protected $subject; /** @var string */ @@ -24,6 +27,23 @@ class admin_form extends form /** @var string */ protected $sender_address; + /** + * Construct + * + * @param \phpbb\auth\auth $auth + * @param \phpbb\config\config $config + * @param \phpbb\config\db_text $config_text + * @param \phpbb\db\driver\driver_interface $db + * @param \phpbb\user $user + * @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) + { + parent::__construct($auth, $config, $db, $user, $phpbb_root_path, $phpEx); + $this->config_text = $config_text; + } + /** * {inheritDoc} */ @@ -116,12 +136,15 @@ class admin_form extends form */ public function render(\phpbb\template\template $template) { + // @todo Add option to fill the db with it and add migration + $l_admin_info = '';//$this->config_text['contact_admin_info']; + $template->assign_vars(array( 'S_CONTACT_ADMIN' => true, 'S_CONTACT_FORM' => $this->config['contact_admin_form_enable'], 'S_IS_REGISTERED' => $this->user->data['is_registered'], - 'CONTACT_INFO' => '', /** TODO: $this->config['contact_admin_info'] */ + 'CONTACT_INFO' => $l_admin_info, 'MESSAGE' => $this->body, 'SUBJECT' => $this->subject, 'NAME' => $this->sender_name, -- cgit v1.2.1 From 4f2f3d9757b40fc563300d81e23c3c3935375a5d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 14:04:55 +0200 Subject: [ticket/10073] Display contact info PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/message/admin_form.php') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index f7eddb59dc..7bab96eec2 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -136,8 +136,16 @@ class admin_form extends form */ public function render(\phpbb\template\template $template) { - // @todo Add option to fill the db with it and add migration - $l_admin_info = '';//$this->config_text['contact_admin_info']; + $l_admin_info = $this->config_text->get('contact_admin_info'); + if ($l_admin_info) + { + $l_admin_info = generate_text_for_display( + $this->config_text->get('contact_admin_info'), + $this->config['contact_admin_info_uid'], + $this->config['contact_admin_info_bitfield'], + $this->config['contact_admin_info_flags'] + ); + } $template->assign_vars(array( 'S_CONTACT_ADMIN' => true, -- cgit v1.2.1 From 427d70d1387090befbff4b0d2f24efd84cfc0392 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 May 2014 17:01:13 +0200 Subject: [ticket/10073] Use phpbb_validate_email to verify email address PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/message/admin_form.php') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index 7bab96eec2..aa185da740 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -101,9 +101,27 @@ class admin_form extends form { $this->errors[] = $this->user->lang['EMPTY_SENDER_NAME']; } - if (!$this->sender_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->sender_address)) + + if (!function_exists('validate_data')) + { + require($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx); + } + + $validate_array = validate_data( + array( + 'email' => $this->sender_address, + ), + array( + 'email' => array( + array('string', false, 6, 60), + array('email'), + ), + ) + ); + + foreach ($validate_array as $error) { - $this->errors[] = $this->user->lang['EMPTY_SENDER_EMAIL']; + $this->errors[] = $this->user->lang[$error]; } $this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name); -- cgit v1.2.1 From e2e7e2a55bffc709ac690c0130fed2bc33dd1b07 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 May 2014 21:32:17 +0200 Subject: [ticket/10073] Move config values to config_text PHPBB3-10073 --- phpBB/phpbb/message/admin_form.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/message/admin_form.php') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index aa185da740..b71b3fc535 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -157,11 +157,18 @@ class admin_form extends form $l_admin_info = $this->config_text->get('contact_admin_info'); if ($l_admin_info) { + $contact_admin_data = $this->config_text->get_array(array( + 'contact_admin_info', + 'contact_admin_info_uid', + 'contact_admin_info_bitfield', + 'contact_admin_info_flags', + )); + $l_admin_info = generate_text_for_display( - $this->config_text->get('contact_admin_info'), - $this->config['contact_admin_info_uid'], - $this->config['contact_admin_info_bitfield'], - $this->config['contact_admin_info_flags'] + $contact_admin_data['contact_admin_info'], + $contact_admin_data['contact_admin_info_uid'], + $contact_admin_data['contact_admin_info_bitfield'], + $contact_admin_data['contact_admin_info_flags'] ); } -- cgit v1.2.1 From 32a2c95f903cbbfad909945887a1cbabd84d5039 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 20 Jun 2014 15:02:08 +0200 Subject: [ticket/12723] Add Sniff ensuring PHP files use the correct file header PHPBB3-12723 --- phpBB/phpbb/message/admin_form.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/message/admin_form.php') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index b71b3fc535..93db59880c 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -12,8 +16,6 @@ namespace phpbb\message; /** * Class admin_form * Displays a message to the user and allows him to send an email -* -* @package phpbb\message */ class admin_form extends form { -- cgit v1.2.1 From 85031a66cc8f095f0e9ce2d281358719d7744eb1 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 5 Nov 2014 20:59:38 +0100 Subject: [ticket/13242] Fix HTML validity PHPBB3-13242 --- phpBB/phpbb/message/admin_form.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/message/admin_form.php') diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index 93db59880c..96b8d3499e 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -178,6 +178,7 @@ class admin_form extends form 'S_CONTACT_ADMIN' => true, 'S_CONTACT_FORM' => $this->config['contact_admin_form_enable'], 'S_IS_REGISTERED' => $this->user->data['is_registered'], + 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=contactadmin'), 'CONTACT_INFO' => $l_admin_info, 'MESSAGE' => $this->body, -- cgit v1.2.1