Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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 |
admin_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 admin_form
018 * Displays a message to the user and allows him to send an email
019 */
020 class admin_form extends form
021 {
022 /** @var \phpbb\config\db_text */
023 protected $config_text;
024
025 /** @var \phpbb\event\dispatcher_interface */
026 protected $dispatcher;
027
028 /** @var string */
029 protected $subject;
030 /** @var string */
031 protected $sender_name;
032 /** @var string */
033 protected $sender_address;
034
035 /**
036 * Construct
037 *
038 * @param \phpbb\auth\auth $auth
039 * @param \phpbb\config\config $config
040 * @param \phpbb\config\db_text $config_text
041 * @param \phpbb\db\driver\driver_interface $db
042 * @param \phpbb\user $user
043 * @param \phpbb\event\dispatcher_interface $dispatcher
044 * @param string $phpbb_root_path
045 * @param string $phpEx
046 */
047 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)
048 {
049 parent::__construct($auth, $config, $db, $user, $phpbb_root_path, $phpEx);
050 $this->config_text = $config_text;
051 $this->dispatcher = $dispatcher;
052 }
053
054 /**
055 * {inheritDoc}
056 */
057 public function check_allow()
058 {
059 $error = parent::check_allow();
060 if ($error)
061 {
062 return $error;
063 }
064
065 if (!$this->config['contact_admin_form_enable'])
066 {
067 return 'NO_CONTACT_PAGE';
068 }
069
070 return false;
071 }
072
073 /**
074 * {inheritDoc}
075 */
076 public function bind(\phpbb\request\request_interface $request)
077 {
078 parent::bind($request);
079
080 $this->subject = $request->variable('subject', '', true);
081 $this->sender_address = $request->variable('email', '');
082 $this->sender_name = $request->variable('name', '', true);
083 }
084
085 /**
086 * {inheritDoc}
087 */
088 public function submit(\messenger $messenger)
089 {
090 if (!$this->subject)
091 {
092 $this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL'];
093 }
094 if (!$this->body)
095 {
096 $this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL'];
097 }
098
099 $subject = $this->subject;
100 $body = $this->body;
101 $errors = $this->errors;
102
103 /**
104 * You can use this event to modify subject and/or body and add new errors.
105 *
106 * @event core.message_admin_form_submit_before
107 * @var string subject Message subject
108 * @var string body Message body
109 * @var array errors Form errors
110 * @since 3.2.6-RC1
111 */
112 $vars = [
113 'subject',
114 'body',
115 'errors',
116 ];
117 extract($this->dispatcher->trigger_event('core.message_admin_form_submit_before', compact($vars)));
118 $this->subject = $subject;
119 $this->body = $body;
120 $this->errors = $errors;
121
122 if ($this->user->data['is_registered'])
123 {
124 $this->message->set_sender_from_user($this->user);
125 $this->sender_name = $this->user->data['username'];
126 $this->sender_address = $this->user->data['user_email'];
127 }
128 else
129 {
130 if (!$this->sender_name)
131 {
132 $this->errors[] = $this->user->lang['EMPTY_SENDER_NAME'];
133 }
134
135 if (!function_exists('validate_data'))
136 {
137 require($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx);
138 }
139
140 $validate_array = validate_data(
141 array(
142 'email' => $this->sender_address,
143 ),
144 array(
145 'email' => array(
146 array('string', false, 6, 60),
147 array('email'),
148 ),
149 )
150 );
151
152 foreach ($validate_array as $error)
153 {
154 $this->errors[] = $this->user->lang[$error];
155 }
156
157 $this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name);
158 $this->message->set_sender_notify_type(NOTIFY_EMAIL);
159 }
160
161 $this->message->set_template('contact_admin');
162 $this->message->set_subject($this->subject);
163 $this->message->set_body($this->body);
164 $this->message->add_recipient(
165 $this->user->lang['ADMINISTRATOR'],
166 $this->config['board_contact'],
167 $this->config['default_lang'],
168 NOTIFY_EMAIL
169 );
170
171 $this->message->set_template_vars(array(
172 'FROM_EMAIL_ADDRESS' => $this->sender_address,
173 'FROM_IP_ADDRESS' => $this->user->ip,
174 'S_IS_REGISTERED' => $this->user->data['is_registered'],
175
176 'U_FROM_PROFILE' => generate_board_url() . '/memberlist.' . $this->phpEx . '?mode=viewprofile&u=' . $this->user->data['user_id'],
177 ));
178
179 parent::submit($messenger);
180 }
181
182 /**
183 * {inheritDoc}
184 */
185 public function render(\phpbb\template\template $template)
186 {
187 $l_admin_info = $this->config_text->get('contact_admin_info');
188 if ($l_admin_info)
189 {
190 $contact_admin_data = $this->config_text->get_array(array(
191 'contact_admin_info',
192 'contact_admin_info_uid',
193 'contact_admin_info_bitfield',
194 'contact_admin_info_flags',
195 ));
196
197 $l_admin_info = generate_text_for_display(
198 $contact_admin_data['contact_admin_info'],
199 $contact_admin_data['contact_admin_info_uid'],
200 $contact_admin_data['contact_admin_info_bitfield'],
201 $contact_admin_data['contact_admin_info_flags']
202 );
203 }
204
205 $template->assign_vars(array(
206 'S_CONTACT_ADMIN' => true,
207 'S_CONTACT_FORM' => $this->config['contact_admin_form_enable'],
208 'S_IS_REGISTERED' => $this->user->data['is_registered'],
209 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=contactadmin'),
210
211 'CONTACT_INFO' => $l_admin_info,
212 'MESSAGE' => $this->body,
213 'SUBJECT' => $this->subject,
214 'NAME' => $this->sender_name,
215 'EMAIL' => $this->sender_address,
216 ));
217
218 parent::render($template);
219 }
220 }
221