aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/message/user_form.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-04-11 18:09:25 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-05-29 02:14:29 +0200
commitfffb07fd91b42d64e71e16a13bcdde87114fad19 (patch)
treeb0733d3cc0fab9186b1090b91a4671401d6c1765 /phpBB/phpbb/message/user_form.php
parent6c287e57fc3d93b98632d19933968ce1bed9dee2 (diff)
downloadforums-fffb07fd91b42d64e71e16a13bcdde87114fad19.tar
forums-fffb07fd91b42d64e71e16a13bcdde87114fad19.tar.gz
forums-fffb07fd91b42d64e71e16a13bcdde87114fad19.tar.bz2
forums-fffb07fd91b42d64e71e16a13bcdde87114fad19.tar.xz
forums-fffb07fd91b42d64e71e16a13bcdde87114fad19.zip
[ticket/10073] Use namespaces and fix all class names
PHPBB3-10073
Diffstat (limited to 'phpBB/phpbb/message/user_form.php')
-rw-r--r--phpBB/phpbb/message/user_form.php106
1 files changed, 106 insertions, 0 deletions
diff --git a/phpBB/phpbb/message/user_form.php b/phpBB/phpbb/message/user_form.php
new file mode 100644
index 0000000000..a76d553b7c
--- /dev/null
+++ b/phpBB/phpbb/message/user_form.php
@@ -0,0 +1,106 @@
+<?php
+/**
+*
+* @package message
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace phpbb\message;
+
+class user_form extends form
+{
+ protected $recipient_id;
+ protected $subject;
+ protected $recipient_row;
+
+ public function check_allow()
+ {
+ $error = parent::check_allow();
+ if ($error)
+ {
+ return $error;
+ }
+
+ if (!$this->auth->acl_get('u_sendemail'))
+ {
+ return 'NO_EMAIL';
+ }
+
+ if ($this->recipient_id == ANONYMOUS || !$this->config['board_email_form'])
+ {
+ return 'NO_EMAIL';
+ }
+
+ if (!$this->recipient_row)
+ {
+ return 'NO_USER';
+ }
+
+ // Can we send email to this user?
+ if (!$this->recipient_row['user_allow_viewemail'] && !$this->auth->acl_get('a_user'))
+ {
+ return 'NO_EMAIL';
+ }
+
+ return false;
+ }
+
+ protected function get_user_row($user_id)
+ {
+ $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type
+ FROM ' . USERS_TABLE . '
+ WHERE user_id = ' . ((int) $user_id) . '
+ AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ return $row;
+ }
+
+ public function bind(\phpbb\request\request_interface $request)
+ {
+ parent::bind($request);
+
+ $this->recipient_id = $request->variable('u', 0);
+ $this->subject = $request->variable('subject', '', true);
+
+ $this->recipient_row = $this->get_user_row($this->recipient_id);
+ }
+
+ 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'];
+ }
+
+ $this->message->set_template('profile_send_email');
+ $this->message->set_subject($this->subject);
+ $this->message->set_body($this->body);
+ $this->message->add_recipient_from_user_row($this->recipient_row);
+
+ parent::submit($messenger);
+ }
+
+ public function render(\phpbb\template\template $template)
+ {
+ parent::render($template);
+
+ $template->assign_vars(array(
+ 'S_SEND_USER' => true,
+ 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&amp;u=' . $this->recipient_id),
+
+ 'USERNAME' => $this->recipient_row['username'],
+ 'SUBJECT' => $this->subject,
+ 'MESSAGE' => $this->body,
+ ));
+ }
+}