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_closed.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 * PM report closed notifications class
018 * This class handles notifications for when reports are closed on PMs (for the one who reported the PM)
019 */
020
021 class report_pm_closed 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_closed';
031 }
032
033 /**
034 * Email template to use to send notifications
035 *
036 * @var string
037 */
038 public $email_template = 'report_pm_closed';
039
040 /**
041 * Language key used to output the text
042 *
043 * @var string
044 */
045 protected $language_key = 'NOTIFICATION_REPORT_PM_CLOSED';
046
047 /**
048 * Notification option data (for outputting to the user)
049 *
050 * @var bool|array False if the service should use it's default data
051 * Array of data (including keys 'id', 'lang', and 'group')
052 */
053 static public $notification_option = [
054 'id' => 'notification.type.report_pm_closed',
055 'lang' => 'NOTIFICATION_TYPE_REPORT_PM_CLOSED',
056 'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS',
057 ];
058
059 public function is_available()
060 {
061 return (bool) $this->config['allow_pm_report'];
062 }
063
064 /**
065 * Find the users who want to receive notifications
066 *
067 * @param array $pm Data from submit_pm
068 * @param array $options Options for finding users for notification
069 *
070 * @return array
071 */
072 public function find_users_for_notification($pm, $options = [])
073 {
074 $options = array_merge([
075 'ignore_users' => [],
076 ], $options);
077
078 if ($pm['reporter'] == $this->user->data['user_id'])
079 {
080 return [];
081 }
082
083 return $this->check_user_notification_options([$pm['reporter']], $options);
084 }
085
086 /**
087 * Get email template
088 *
089 * @return string|bool
090 */
091 public function get_email_template()
092 {
093 return $this->email_template;
094 }
095
096 /**
097 * Get email template variables
098 *
099 * @return array
100 */
101 public function get_email_template_variables()
102 {
103 $sender_username = $this->user_loader->get_username($this->get_data('from_user_id'), 'username');
104 $closer_username = $this->user_loader->get_username($this->get_data('closer_id'), 'username');
105
106 return [
107 'AUTHOR_NAME' => html_entity_decode($sender_username, ENT_COMPAT),
108 'CLOSER_NAME' => html_entity_decode($closer_username, ENT_COMPAT),
109 'SUBJECT' => html_entity_decode(censor_text($this->get_data('message_subject')), ENT_COMPAT),
110
111 'U_VIEW_MESSAGE'=> generate_board_url() . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$this->item_id}",
112 ];
113 }
114
115 /**
116 * Get the HTML formatted title of this notification
117 *
118 * @return string
119 */
120 public function get_title()
121 {
122 $username = $this->user_loader->get_username($this->get_data('closer_id'), 'no_profile');
123
124 return $this->language->lang(
125 $this->language_key,
126 $username
127 );
128 }
129
130 /**
131 * Get the HTML formatted reference of the notification
132 *
133 * @return string
134 */
135 public function get_reference()
136 {
137 return $this->language->lang(
138 'NOTIFICATION_REFERENCE',
139 censor_text($this->get_data('message_subject'))
140 );
141 }
142
143 /**
144 * Get the user's avatar
145 */
146 public function get_avatar()
147 {
148 return $this->user_loader->get_avatar($this->get_data('closer_id'), false, true);
149 }
150
151 /**
152 * Users needed to query before this notification can be displayed
153 *
154 * @return array Array of user_ids
155 */
156 public function users_to_query()
157 {
158 return [$this->get_data('closer_id')];
159 }
160
161 /**
162 * {@inheritdoc}
163 */
164 public function create_insert_array($pm, $pre_create_data = [])
165 {
166 $this->set_data('closer_id', $pm['closer_id']);
167
168 parent::create_insert_array($pm, $pre_create_data);
169
170 $this->notification_time = time();
171 }
172
173 /**
174 * {@inheritdoc}
175 */
176 public function get_insert_array()
177 {
178 $data = parent::get_insert_array();
179 $data['notification_time'] = $this->notification_time;
180
181 return $data;
182 }
183 }
184