[ Index ]

PHP Cross Reference of phpBB-3.3.2-deutsch

title

Body

[close]

/phpbb/report/ -> report_handler_pm.php (source)

   1  <?php
   2  /**
   3   *
   4   * This file is part of the phpBB Forum Software package.
   5   *
   6   * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7   * @license GNU General Public License, version 2 (GPL-2.0)
   8   *
   9   * For full copyright and license information, please see
  10   * the docs/CREDITS.txt file.
  11   *
  12   */
  13  
  14  namespace phpbb\report;
  15  
  16  use phpbb\report\exception\empty_report_exception;
  17  use phpbb\report\exception\already_reported_exception;
  18  use phpbb\report\exception\pm_reporting_disabled_exception;
  19  use phpbb\report\exception\entity_not_found_exception;
  20  
  21  class report_handler_pm extends report_handler
  22  {
  23      /**
  24       * {@inheritdoc}
  25       * @throws \phpbb\report\exception\pm_reporting_disabled_exception when PM reporting is disabled on the board
  26       */
  27  	public function add_report($id, $reason_id, $report_text, $user_notify)
  28      {
  29          // Cast the input variables
  30          $id                = (int) $id;
  31          $reason_id        = (int) $reason_id;
  32          $report_text    = (string) $report_text;
  33          $user_notify    = (int) $user_notify;
  34  
  35          $this->validate_report_request($id);
  36  
  37          $sql = 'SELECT *
  38              FROM ' . REPORTS_REASONS_TABLE . "
  39              WHERE reason_id = $reason_id";
  40          $result = $this->db->sql_query($sql);
  41          $row = $this->db->sql_fetchrow($result);
  42          $this->db->sql_freeresult($result);
  43  
  44          if (!$row || (empty($report_text) && strtolower($row['reason_title']) === 'other'))
  45          {
  46              throw new empty_report_exception();
  47          }
  48  
  49          $report_data = array(
  50              'reason_id'                            => $reason_id,
  51              'post_id'                            => 0,
  52              'pm_id'                                => $id,
  53              'user_notify'                        => $user_notify,
  54              'report_text'                        => $report_text,
  55              'reported_post_text'                => $this->report_data['message_text'],
  56              'reported_post_uid'                    => $this->report_data['bbcode_uid'],
  57              'reported_post_bitfield'            => $this->report_data['bbcode_bitfield'],
  58              'reported_post_enable_bbcode'        => $this->report_data['enable_bbcode'],
  59              'reported_post_enable_smilies'        => $this->report_data['enable_smilies'],
  60              'reported_post_enable_magic_url'    => $this->report_data['enable_magic_url'],
  61          );
  62  
  63          $report_id = $this->create_report($report_data);
  64  
  65          $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
  66              SET message_reported = 1
  67              WHERE msg_id = ' . $id;
  68          $this->db->sql_query($sql);
  69  
  70          $sql_ary = array(
  71              'msg_id'        => $id,
  72              'user_id'        => ANONYMOUS,
  73              'author_id'        => (int) $this->report_data['author_id'],
  74              'pm_deleted'    => 0,
  75              'pm_new'        => 0,
  76              'pm_unread'        => 0,
  77              'pm_replied'    => 0,
  78              'pm_marked'        => 0,
  79              'pm_forwarded'    => 0,
  80              'folder_id'        => PRIVMSGS_INBOX,
  81          );
  82  
  83          $sql = 'INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
  84          $this->db->sql_query($sql);
  85  
  86          $this->notifications->add_notifications('notification.type.report_pm', array_merge($this->report_data, $row, array(
  87              'report_text'    => $report_text,
  88              'from_user_id'    => $this->report_data['author_id'],
  89              'report_id'        => $report_id,
  90          )));
  91      }
  92  
  93      /**
  94       * {@inheritdoc}
  95       * @throws \phpbb\report\exception\pm_reporting_disabled_exception when PM reporting is disabled on the board
  96       */
  97  	public function validate_report_request($id)
  98      {
  99          $id = (int) $id;
 100  
 101          // Check if reporting PMs is enabled
 102          if (!$this->config['allow_pm_report'])
 103          {
 104              throw new pm_reporting_disabled_exception();
 105          }
 106          else if ($id <= 0)
 107          {
 108              throw new entity_not_found_exception('NO_POST_SELECTED');
 109          }
 110  
 111          // Grab all relevant data
 112          $sql = 'SELECT p.*, pt.*
 113              FROM ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TO_TABLE . " pt
 114              WHERE p.msg_id = $id
 115                  AND p.msg_id = pt.msg_id
 116                  AND (p.author_id = " . $this->user->data['user_id'] . "
 117                      OR pt.user_id = " . $this->user->data['user_id'] . ")";
 118          $result = $this->db->sql_query($sql);
 119          $report_data = $this->db->sql_fetchrow($result);
 120          $this->db->sql_freeresult($result);
 121  
 122          // Check if message exists
 123          if (!$report_data)
 124          {
 125              $this->user->add_lang('ucp');
 126              throw new entity_not_found_exception('NO_MESSAGE');
 127          }
 128  
 129          // Check if message is already reported
 130          if ($report_data['message_reported'])
 131          {
 132              throw new already_reported_exception();
 133          }
 134  
 135          $this->report_data = $report_data;
 136      }
 137  }


Generated: Wed Nov 11 20:28:18 2020 Cross-referenced by PHPXref 0.7.1