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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
report_handler_pm.php
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\empty_report_exception;
017 use phpbb\report\exception\already_reported_exception;
018 use phpbb\report\exception\pm_reporting_disabled_exception;
019 use phpbb\report\exception\entity_not_found_exception;
020
021 class report_handler_pm extends report_handler
022 {
023 /**
024 * {@inheritdoc}
025 * @throws pm_reporting_disabled_exception when PM reporting is disabled on the board
026 */
027 public function add_report($id, $reason_id, $report_text, $user_notify)
028 {
029 // Cast the input variables
030 $id = (int) $id;
031 $reason_id = (int) $reason_id;
032 $report_text = (string) $report_text;
033 $user_notify = (int) $user_notify;
034
035 $this->validate_report_request($id);
036
037 $sql = 'SELECT *
038 FROM ' . REPORTS_REASONS_TABLE . "
039 WHERE reason_id = $reason_id";
040 $result = $this->db->sql_query($sql);
041 $row = $this->db->sql_fetchrow($result);
042 $this->db->sql_freeresult($result);
043
044 if (!$row || (empty($report_text) && strtolower($row['reason_title']) === 'other'))
045 {
046 throw new empty_report_exception();
047 }
048
049 $report_data = array(
050 'reason_id' => $reason_id,
051 'post_id' => 0,
052 'pm_id' => $id,
053 'user_notify' => $user_notify,
054 'report_text' => $report_text,
055 'reported_post_text' => $this->report_data['message_text'],
056 'reported_post_uid' => $this->report_data['bbcode_uid'],
057 'reported_post_bitfield' => $this->report_data['bbcode_bitfield'],
058 'reported_post_enable_bbcode' => $this->report_data['enable_bbcode'],
059 'reported_post_enable_smilies' => $this->report_data['enable_smilies'],
060 'reported_post_enable_magic_url' => $this->report_data['enable_magic_url'],
061 );
062
063 $report_id = $this->create_report($report_data);
064
065 $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
066 SET message_reported = 1
067 WHERE msg_id = ' . $id;
068 $this->db->sql_query($sql);
069
070 $sql_ary = array(
071 'msg_id' => $id,
072 'user_id' => ANONYMOUS,
073 'author_id' => (int) $this->report_data['author_id'],
074 'pm_deleted' => 0,
075 'pm_new' => 0,
076 'pm_unread' => 0,
077 'pm_replied' => 0,
078 'pm_marked' => 0,
079 'pm_forwarded' => 0,
080 'folder_id' => PRIVMSGS_INBOX,
081 );
082
083 $sql = 'INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
084 $this->db->sql_query($sql);
085
086 $this->notifications->add_notifications('notification.type.report_pm', array_merge($this->report_data, $row, array(
087 'report_text' => $report_text,
088 'from_user_id' => $this->report_data['author_id'],
089 'report_id' => $report_id,
090 )));
091 }
092
093 /**
094 * {@inheritdoc}
095 * @throws pm_reporting_disabled_exception when PM reporting is disabled on the board
096 */
097 public function validate_report_request($id)
098 {
099 $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 }
138