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 |
report_pm.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\notification\type;
015
016 /**
017 * Private message reported notifications class
018 * This class handles notifications for private messages when they are reported
019 */
020
021 class report_pm extends \phpbb\notification\type\pm
022 {
023 /**
024 * Get notification type name
025 *
026 * @return string
027 */
028 public function get_type()
029 {
030 return 'notification.type.report_pm';
031 }
032
033 /**
034 * Get the CSS style class of the notification
035 *
036 * @return string
037 */
038 public function get_style_class()
039 {
040 return 'notification-reported';
041 }
042
043 /**
044 * Language key used to output the text
045 *
046 * @var string
047 */
048 protected $language_key = 'NOTIFICATION_REPORT_PM';
049
050 /**
051 * Permission to check for (in find_users_for_notification)
052 *
053 * @var string Permission name
054 */
055 protected $permission = 'm_pm_report';
056
057 /**
058 * Notification option data (for outputting to the user)
059 *
060 * @var bool|array False if the service should use it's default data
061 * Array of data (including keys 'id', 'lang', and 'group')
062 */
063 static public $notification_option = [
064 'id' => 'notification.type.report_pm',
065 'lang' => 'NOTIFICATION_TYPE_REPORT_PM',
066 'group' => 'NOTIFICATION_GROUP_MODERATION',
067 ];
068
069 /**
070 * Get the id of the parent
071 *
072 * @param array $pm The data from the pm
073 * @return int The report id
074 */
075 static public function get_item_parent_id($pm)
076 {
077 return (int) $pm['report_id'];
078 }
079
080 /**
081 * Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options)
082 *
083 * @return bool True/False whether or not this is available to the user
084 */
085 public function is_available()
086 {
087 return $this->config['allow_pm_report'] &&
088 !empty($this->auth->acl_get($this->permission));
089 }
090
091 /**
092 * Find the users who want to receive notifications
093 * (copied from post_in_queue)
094 *
095 * @param array $post Data from the post
096 * @param array $options Options for finding users for notification
097 *
098 * @return array
099 */
100 public function find_users_for_notification($post, $options = [])
101 {
102 $options = array_merge([
103 'ignore_users' => [],
104 ], $options);
105
106 // Global
107 $post['forum_id'] = 0;
108
109 $auth_approve = $this->auth->acl_get_list(false, $this->permission, $post['forum_id']);
110
111 if (empty($auth_approve))
112 {
113 return [];
114 }
115
116 if (($key = array_search($this->user->data['user_id'], $auth_approve[$post['forum_id']][$this->permission])))
117 {
118 unset($auth_approve[$post['forum_id']][$this->permission][$key]);
119 }
120
121 return $this->check_user_notification_options($auth_approve[$post['forum_id']][$this->permission], array_merge($options, [
122 'item_type' => static::$notification_option['id'],
123 ]));
124 }
125
126 /**
127 * Get email template
128 *
129 * @return string|bool
130 */
131 public function get_email_template()
132 {
133 return 'report_pm';
134 }
135
136 /**
137 * Get email template variables
138 *
139 * @return array
140 */
141 public function get_email_template_variables()
142 {
143 $user_data = $this->user_loader->get_user($this->get_data('from_user_id'));
144
145 return [
146 'AUTHOR_NAME' => html_entity_decode($user_data['username'], ENT_COMPAT),
147 'SUBJECT' => html_entity_decode(censor_text($this->get_data('message_subject')), ENT_COMPAT),
148
149 /** @deprecated 3.2.6-RC1 (to be removed in 4.0.0) use {SUBJECT} instead in report_pm.txt */
150 'TOPIC_TITLE' => html_entity_decode(censor_text($this->get_data('message_subject')), ENT_COMPAT),
151
152 'U_VIEW_REPORT' => generate_board_url() . "/mcp.{$this->php_ext}?r={$this->item_parent_id}&i=pm_reports&mode=pm_report_details",
153 ];
154 }
155
156 /**
157 * Get the url to this item
158 *
159 * @return string URL
160 */
161 public function get_url()
162 {
163 return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "r={$this->item_parent_id}&i=pm_reports&mode=pm_report_details");
164 }
165
166 /**
167 * Get the HTML formatted title of this notification
168 *
169 * @return string
170 */
171 public function get_title()
172 {
173 $this->language->add_lang('mcp');
174
175 $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
176
177 return $this->language->lang(
178 $this->language_key,
179 $username
180 );
181 }
182
183 /**
184 * Get the HTML formatted reference of the notification
185 *
186 * @return string
187 */
188 public function get_reference()
189 {
190 return $this->language->lang(
191 'NOTIFICATION_REFERENCE',
192 censor_text($this->get_data('message_subject'))
193 );
194 }
195
196 /**
197 * Get the reason for the notification
198 *
199 * @return string
200 */
201 public function get_reason()
202 {
203 if ($this->get_data('report_text'))
204 {
205 return $this->language->lang(
206 'NOTIFICATION_REASON',
207 $this->get_data('report_text')
208 );
209 }
210
211 if ($this->language->is_set($this->get_data('reason_title')))
212 {
213 return $this->language->lang(
214 'NOTIFICATION_REASON',
215 $this->language->lang($this->get_data('reason_title'))
216 );
217 }
218
219 return $this->language->lang(
220 'NOTIFICATION_REASON',
221 $this->get_data('reason_description')
222 );
223 }
224
225 /**
226 * Get the user's avatar
227 */
228 public function get_avatar()
229 {
230 return $this->user_loader->get_avatar($this->get_data('reporter_id'), false, true);
231 }
232
233 /**
234 * Users needed to query before this notification can be displayed
235 *
236 * @return array Array of user_ids
237 */
238 public function users_to_query()
239 {
240 return [
241 $this->get_data('from_user_id'),
242 $this->get_data('reporter_id'),
243 ];
244 }
245
246 /**
247 * {@inheritdoc}
248 */
249 public function create_insert_array($post, $pre_create_data = [])
250 {
251 $this->set_data('reporter_id', $this->user->data['user_id']);
252 $this->set_data('reason_title', strtoupper($post['reason_title']));
253 $this->set_data('reason_description', $post['reason_description']);
254 $this->set_data('report_text', $post['report_text']);
255
256 parent::create_insert_array($post, $pre_create_data);
257 }
258 }
259