Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

report_pm.php

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 5.58 KiB


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 = array(
064          'id'    => 'notification.type.report',
065          'lang'    => 'NOTIFICATION_TYPE_REPORT',
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          $m_approve = $this->auth->acl_getf($this->permission, true);
088   
089          return (!empty($m_approve));
090      }
091   
092   
093      /**
094      * Find the users who want to receive notifications
095      *  (copied from post_in_queue)
096      *
097      * @param array $post Data from the post
098      * @param array $options Options for finding users for notification
099      *
100      * @return array
101      */
102      public function find_users_for_notification($post, $options = array())
103      {
104          $options = array_merge(array(
105              'ignore_users'        => array(),
106          ), $options);
107   
108          // Global
109          $post['forum_id'] = 0;
110   
111          $auth_approve = $this->auth->acl_get_list(false, $this->permission, $post['forum_id']);
112   
113          if (empty($auth_approve))
114          {
115              return array();
116          }
117   
118          if (($key = array_search($this->user->data['user_id'], $auth_approve[$post['forum_id']][$this->permission])))
119          {
120              unset($auth_approve[$post['forum_id']][$this->permission][$key]);
121          }
122   
123          return $this->check_user_notification_options($auth_approve[$post['forum_id']][$this->permission], array_merge($options, array(
124              'item_type'        => static::$notification_option['id'],
125          )));
126      }
127   
128      /**
129      * Get email template
130      *
131      * @return string|bool
132      */
133      public function get_email_template()
134      {
135          return 'report_pm';
136      }
137   
138      /**
139      * Get email template variables
140      *
141      * @return array
142      */
143      public function get_email_template_variables()
144      {
145          $user_data = $this->user_loader->get_user($this->get_data('reporter_id'));
146   
147          return array(
148              'AUTHOR_NAME'    => htmlspecialchars_decode($user_data['username']),
149              'SUBJECT'        => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
150   
151              'U_VIEW_REPORT'    => generate_board_url() . "mcp.{$this->php_ext}?r={$this->item_parent_id}&amp;i=pm_reports&amp;mode=pm_report_details",
152          );
153      }
154   
155      /**
156      * Get the url to this item
157      *
158      * @return string URL
159      */
160      public function get_url()
161      {
162          return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "r={$this->item_parent_id}&amp;i=pm_reports&amp;mode=pm_report_details");
163      }
164   
165      /**
166      * Get the HTML formatted title of this notification
167      *
168      * @return string
169      */
170      public function get_title()
171      {
172          $this->language->add_lang('mcp');
173   
174          $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
175   
176          return $this->language->lang(
177              $this->language_key,
178              $username
179          );
180      }
181   
182      /**
183      * Get the HTML formatted reference of the notification
184      *
185      * @return string
186      */
187      public function get_reference()
188      {
189          return $this->language->lang(
190              'NOTIFICATION_REFERENCE',
191              censor_text($this->get_data('message_subject'))
192          );
193      }
194   
195      /**
196      * Get the reason for the notification
197      *
198      * @return string
199      */
200      public function get_reason()
201      {
202          if ($this->get_data('report_text'))
203          {
204              return $this->language->lang(
205                  'NOTIFICATION_REASON',
206                  $this->get_data('report_text')
207              );
208          }
209   
210          if ($this->language->is_set($this->get_data('reason_title')))
211          {
212              return $this->language->lang(
213                  'NOTIFICATION_REASON',
214                  $this->language->lang($this->get_data('reason_title'))
215              );
216          }
217   
218          return $this->language->lang(
219              'NOTIFICATION_REASON',
220              $this->get_data('reason_description')
221          );
222      }
223   
224      /**
225      * Get the user's avatar
226      */
227      public function get_avatar()
228      {
229          return $this->user_loader->get_avatar($this->get_data('reporter_id'), false, true);
230      }
231   
232      /**
233      * Users needed to query before this notification can be displayed
234      *
235      * @return array Array of user_ids
236      */
237      public function users_to_query()
238      {
239          return array($this->get_data('reporter_id'));
240      }
241   
242      /**
243      * {@inheritdoc}
244      */
245      public function create_insert_array($post, $pre_create_data = array())
246      {
247          $this->set_data('reporter_id', $this->user->data['user_id']);
248          $this->set_data('reason_title', strtoupper($post['reason_title']));
249          $this->set_data('reason_description', $post['reason_description']);
250          $this->set_data('report_text', $post['report_text']);
251   
252          parent::create_insert_array($post, $pre_create_data);
253      }
254  }
255