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