Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
topic_form.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\message;
015
016 /**
017 * Class topic_form
018 * Form used to send topics as notification emails
019 */
020 class topic_form extends form
021 {
022 /** @var int */
023 protected $topic_id;
024 /** @var array */
025 protected $topic_row;
026 /** @var string */
027 protected $recipient_address;
028 /** @var string */
029 protected $recipient_name;
030 /** @var string */
031 protected $recipient_lang;
032
033 /**
034 * Get the data of the topic
035 *
036 * @param int $topic_id
037 * @return false|array false if the topic does not exist, array otherwise
038 */
039 protected function get_topic_row($topic_id)
040 {
041 $sql = 'SELECT forum_id, topic_title
042 FROM ' . TOPICS_TABLE . '
043 WHERE topic_id = ' . (int) $topic_id;
044 $result = $this->db->sql_query($sql);
045 $row = $this->db->sql_fetchrow($result);
046 $this->db->sql_freeresult($result);
047
048 return $row;
049 }
050
051 /**
052 * {inheritDoc}
053 */
054 public function check_allow()
055 {
056 $error = parent::check_allow();
057 if ($error)
058 {
059 return $error;
060 }
061
062 if (!$this->auth->acl_get('u_sendemail'))
063 {
064 return 'NO_EMAIL';
065 }
066
067 if (!$this->topic_row)
068 {
069 return 'NO_TOPIC';
070 }
071
072 if (!$this->auth->acl_get('f_read', $this->topic_row['forum_id']))
073 {
074 return 'SORRY_AUTH_READ';
075 }
076
077 if (!$this->auth->acl_get('f_email', $this->topic_row['forum_id']))
078 {
079 return 'NO_EMAIL';
080 }
081
082 return false;
083 }
084
085 /**
086 * {inheritDoc}
087 */
088 public function bind(\phpbb\request\request_interface $request)
089 {
090 parent::bind($request);
091
092 $this->topic_id = $request->variable('t', 0);
093 $this->recipient_address = $request->variable('email', '');
094 $this->recipient_name = $request->variable('name', '', true);
095 $this->recipient_lang = $request->variable('lang', $this->config['default_lang']);
096
097 $this->topic_row = $this->get_topic_row($this->topic_id);
098 }
099
100 /**
101 * {inheritDoc}
102 */
103 public function submit(\messenger $messenger)
104 {
105 if (!$this->recipient_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->recipient_address))
106 {
107 $this->errors[] = $this->user->lang['EMPTY_ADDRESS_EMAIL'];
108 }
109
110 if (!$this->recipient_name)
111 {
112 $this->errors[] = $this->user->lang['EMPTY_NAME_EMAIL'];
113 }
114
115 $this->message->set_template('email_notify');
116 $this->message->set_template_vars(array(
117 'TOPIC_NAME' => htmlspecialchars_decode($this->topic_row['topic_title']),
118 'U_TOPIC' => generate_board_url() . '/viewtopic.' . $this->phpEx . '?f=' . $this->topic_row['forum_id'] . '&t=' . $this->topic_id,
119 ));
120
121 $this->message->add_recipient(
122 $this->recipient_name,
123 $this->recipient_address,
124 $this->recipient_lang,
125 NOTIFY_EMAIL
126 );
127 $this->message->set_sender_notify_type(NOTIFY_EMAIL);
128
129 parent::submit($messenger);
130 }
131
132 /**
133 * {inheritDoc}
134 */
135 public function get_return_message()
136 {
137 return sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . append_sid($this->phpbb_root_path . 'viewtopic.' . $this->phpEx, 'f=' . $this->topic_row['forum_id'] . '&t=' . $this->topic_id) . '">', '</a>');
138 }
139
140 /**
141 * {inheritDoc}
142 */
143 public function render(\phpbb\template\template $template)
144 {
145 parent::render($template);
146
147 $this->user->add_lang('viewtopic');
148 $template->assign_vars(array(
149 'EMAIL' => $this->recipient_address,
150 'NAME' => $this->recipient_name,
151 'S_LANG_OPTIONS' => language_select($this->recipient_lang),
152 'MESSAGE' => $this->body,
153
154 'L_EMAIL_BODY_EXPLAIN' => $this->user->lang['EMAIL_TOPIC_EXPLAIN'],
155 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&t=' . $this->topic_id))
156 );
157 }
158 }
159