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_post.php

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 5.49 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  * Reported post notifications class
 018  * This class handles notifications for reported posts
 019  */
 020  class report_post extends \phpbb\notification\type\post_in_queue
 021  {
 022      /**
 023      * Get notification type name
 024      *
 025      * @return string
 026      */
 027      public function get_type()
 028      {
 029          return 'notification.type.report_post';
 030      }
 031   
 032      /**
 033      * Get the CSS style class of the notification
 034      *
 035      * @return string
 036      */
 037      public function get_style_class()
 038      {
 039          return 'notification-reported';
 040      }
 041   
 042      /**
 043      * Language key used to output the text
 044      *
 045      * @var string
 046      */
 047      protected $language_key = 'NOTIFICATION_REPORT_POST';
 048   
 049      /**
 050      * Inherit notification read status from post.
 051      *
 052      * @var bool
 053      */
 054      protected $inherit_read_status = false;
 055   
 056      /**
 057      * Permission to check for (in find_users_for_notification)
 058      *
 059      * @var string Permission name
 060      */
 061      protected $permission = 'm_report';
 062   
 063      /**
 064      * Notification option data (for outputting to the user)
 065      *
 066      * @var bool|array False if the service should use it's default data
 067      *                     Array of data (including keys 'id' and 'lang')
 068      */
 069      public static $notification_option = array(
 070          'id'    => 'notification.type.report',
 071          'lang'    => 'NOTIFICATION_TYPE_REPORT',
 072          'group'    => 'NOTIFICATION_GROUP_MODERATION',
 073      );
 074   
 075      /**
 076      * Find the users who want to receive notifications
 077      *
 078      * @param array $post Data from the post
 079      * @param array $options Options for finding users for notification
 080      *
 081      * @return array
 082      */
 083      public function find_users_for_notification($post, $options = array())
 084      {
 085          $notify_users = parent::find_users_for_notification($post, $options);
 086   
 087          // never notify reporter
 088          unset($notify_users[$this->user->data['user_id']]);
 089   
 090          return $notify_users;
 091      }
 092   
 093      /**
 094      * Get email template
 095      *
 096      * @return string|bool
 097      */
 098      public function get_email_template()
 099      {
 100          return 'report_post';
 101      }
 102   
 103      /**
 104      * Get email template variables
 105      *
 106      * @return array
 107      */
 108      public function get_email_template_variables()
 109      {
 110          $board_url = generate_board_url();
 111   
 112          return array(
 113              'POST_SUBJECT'                => htmlspecialchars_decode(censor_text($this->get_data('post_subject'))),
 114              'TOPIC_TITLE'                => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))),
 115   
 116              'U_VIEW_REPORT'                => "{$board_url}/mcp.{$this->php_ext}?f={$this->get_data('forum_id')}&amp;p={$this->item_id}&amp;i=reports&amp;mode=report_details#reports",
 117              'U_VIEW_POST'                => "{$board_url}/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}",
 118              'U_NEWEST_POST'                => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}&view=unread#unread",
 119              'U_TOPIC'                    => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}",
 120              'U_VIEW_TOPIC'                => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}",
 121              'U_FORUM'                    => "{$board_url}/viewforum.{$this->php_ext}?f={$this->get_data('forum_id')}",
 122          );
 123      }
 124   
 125      /**
 126      * Get the url to this item
 127      *
 128      * @return string URL
 129      */
 130      public function get_url()
 131      {
 132          return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "f={$this->get_data('forum_id')}&amp;p={$this->item_id}&amp;i=reports&amp;mode=report_details#reports");
 133      }
 134   
 135      /**
 136      * Get the HTML formatted title of this notification
 137      *
 138      * @return string
 139      */
 140      public function get_title()
 141      {
 142          $this->user->add_lang('mcp');
 143   
 144          $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
 145   
 146          return $this->user->lang(
 147              $this->language_key,
 148              $username
 149          );
 150      }
 151   
 152      /**
 153      * Get the HTML formatted reference of the notification
 154      *
 155      * @return string
 156      */
 157      public function get_reference()
 158      {
 159          return $this->user->lang(
 160              'NOTIFICATION_REFERENCE',
 161              censor_text($this->get_data('post_subject'))
 162          );
 163      }
 164   
 165      /**
 166      * Get the reason for the notification
 167      *
 168      * @return string
 169      */
 170      public function get_reason()
 171      {
 172          if ($this->get_data('report_text'))
 173          {
 174              return $this->user->lang(
 175                  'NOTIFICATION_REASON',
 176                  $this->get_data('report_text')
 177              );
 178          }
 179   
 180          if (isset($this->user->lang[$this->get_data('reason_title')]))
 181          {
 182              return $this->user->lang(
 183                  'NOTIFICATION_REASON',
 184                  $this->user->lang[$this->get_data('reason_title')]
 185              );
 186          }
 187   
 188          return $this->user->lang(
 189              'NOTIFICATION_REASON',
 190              $this->get_data('reason_description')
 191          );
 192      }
 193   
 194      /**
 195      * Get the user's avatar
 196      */
 197      public function get_avatar()
 198      {
 199          return $this->user_loader->get_avatar($this->get_data('reporter_id'));
 200      }
 201   
 202      /**
 203      * Users needed to query before this notification can be displayed
 204      *
 205      * @return array Array of user_ids
 206      */
 207      public function users_to_query()
 208      {
 209          return array($this->get_data('reporter_id'));
 210      }
 211   
 212      /**
 213      * Function for preparing the data for insertion in an SQL query
 214      * (The service handles insertion)
 215      *
 216      * @param array $post Data from submit_post
 217      * @param array $pre_create_data Data from pre_create_insert_array()
 218      *
 219      * @return array Array of data ready to be inserted into the database
 220      */
 221      public function create_insert_array($post, $pre_create_data = array())
 222      {
 223          $this->set_data('reporter_id', $this->user->data['user_id']);
 224          $this->set_data('reason_title', strtoupper($post['reason_title']));
 225          $this->set_data('reason_description', $post['reason_description']);
 226          $this->set_data('report_text', $post['report_text']);
 227   
 228          return parent::create_insert_array($post, $pre_create_data);
 229      }
 230  }
 231