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

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

report_handler_post.php

Zuletzt modifiziert: 02.04.2025, 15:02 - Dateigröße: 4.93 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\report;
015   
016  use phpbb\report\exception\invalid_report_exception;
017  use phpbb\report\exception\empty_report_exception;
018  use phpbb\report\exception\already_reported_exception;
019  use phpbb\report\exception\entity_not_found_exception;
020  use phpbb\report\exception\report_permission_denied_exception;
021   
022  class report_handler_post extends report_handler
023  {
024      /**
025       * @var array
026       */
027      protected $forum_data;
028   
029      /**
030       * {@inheritdoc}
031       * @throws report_permission_denied_exception when the user does not have permission to report the post
032       */
033      public function add_report($id, $reason_id, $report_text, $user_notify)
034      {
035          // Cast the input variables
036          $id                = (int) $id;
037          $reason_id        = (int) $reason_id;
038          $report_text    = (string) $report_text;
039          $user_notify    = (int) $user_notify;
040   
041          $this->validate_report_request($id);
042   
043          $sql = 'SELECT *
044              FROM ' . REPORTS_REASONS_TABLE . "
045              WHERE reason_id = $reason_id";
046          $result = $this->db->sql_query($sql);
047          $row = $this->db->sql_fetchrow($result);
048          $this->db->sql_freeresult($result);
049   
050          if (!$row || (empty($report_text) && strtolower($row['reason_title']) === 'other'))
051          {
052              throw new empty_report_exception();
053          }
054   
055          $report_data = array(
056              'reason_id'                            => $reason_id,
057              'post_id'                            => $id,
058              'pm_id'                                => 0,
059              'user_notify'                        => $user_notify,
060              'report_text'                        => $report_text,
061              'reported_post_text'                => $this->report_data['post_text'],
062              'reported_post_uid'                    => $this->report_data['bbcode_uid'],
063              'reported_post_bitfield'            => $this->report_data['bbcode_bitfield'],
064              'reported_post_enable_bbcode'        => $this->report_data['enable_bbcode'],
065              'reported_post_enable_smilies'        => $this->report_data['enable_smilies'],
066              'reported_post_enable_magic_url'    => $this->report_data['enable_magic_url'],
067          );
068   
069          $this->create_report($report_data);
070   
071          $sql = 'UPDATE ' . POSTS_TABLE . '
072              SET post_reported = 1
073              WHERE post_id = ' . $id;
074          $this->db->sql_query($sql);
075   
076          if (!$this->report_data['topic_reported'])
077          {
078              $sql = 'UPDATE ' . TOPICS_TABLE . '
079                  SET topic_reported = 1
080                  WHERE topic_id = ' . $this->report_data['topic_id'] . '
081                      OR topic_moved_id = ' . $this->report_data['topic_id'];
082              $this->db->sql_query($sql);
083          }
084   
085          $this->notifications->add_notifications('notification.type.report_post', array_merge($this->report_data, $row, $this->forum_data, array(
086              'report_text'    => $report_text,
087          )));
088      }
089   
090      /**
091       * {@inheritdoc}
092       * @throws report_permission_denied_exception when the user does not have permission to report the post
093       */
094      public function validate_report_request($id)
095      {
096          $id = (int) $id;
097   
098          // Check if id is valid
099          if ($id <= 0)
100          {
101              throw new entity_not_found_exception('NO_POST_SELECTED');
102          }
103   
104          // Grab all relevant data
105          $sql = 'SELECT t.*, p.*
106              FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
107              WHERE p.post_id = $id
108                  AND p.topic_id = t.topic_id";
109          $result = $this->db->sql_query($sql);
110          $report_data = $this->db->sql_fetchrow($result);
111          $this->db->sql_freeresult($result);
112   
113          if (!$report_data)
114          {
115              throw new entity_not_found_exception('POST_NOT_EXIST');
116          }
117   
118          $forum_id = (int) $report_data['forum_id'];
119   
120          $sql = 'SELECT *
121              FROM ' . FORUMS_TABLE . '
122              WHERE forum_id = ' . $forum_id;
123          $result = $this->db->sql_query($sql);
124          $forum_data = $this->db->sql_fetchrow($result);
125          $this->db->sql_freeresult($result);
126   
127          if (!$forum_data)
128          {
129              throw new invalid_report_exception('FORUM_NOT_EXIST');
130          }
131   
132          $acl_check_ary = array(
133              'f_list' => 'POST_NOT_EXIST',
134              'f_read' => 'USER_CANNOT_READ',
135              'f_report' => 'USER_CANNOT_REPORT'
136          );
137   
138          /**
139           * This event allows you to do extra auth checks and verify if the user
140           * has the required permissions
141           *
142           * @event core.report_post_auth
143           * @var    array    forum_data        All data available from the forums table on this post's forum
144           * @var    array    report_data        All data available from the topics and the posts tables on this post (and its topic)
145           * @var    array    acl_check_ary    An array with the ACL to be tested. The evaluation is made in the same order as the array is sorted
146           *                                The key is the ACL name and the value is the language key for the error message.
147           * @since 3.1.3-RC1
148           */
149          $vars = array(
150              'forum_data',
151              'report_data',
152              'acl_check_ary',
153          );
154          extract($this->dispatcher->trigger_event('core.report_post_auth', compact($vars)));
155   
156          $this->auth->acl($this->user->data);
157   
158          foreach ($acl_check_ary as $acl => $error)
159          {
160              if (!$this->auth->acl_get($acl, $forum_id))
161              {
162                  throw new report_permission_denied_exception($error);
163              }
164          }
165          unset($acl_check_ary);
166   
167          if ($report_data['post_reported'])
168          {
169              throw new already_reported_exception();
170          }
171   
172          $this->report_data    = $report_data;
173          $this->forum_data    = $forum_data;
174      }
175  }
176