Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| report_handler | |
0.00% |
0 / 26 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| create_report | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
2 | |||
| 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 | abstract class report_handler implements report_handler_interface |
| 17 | { |
| 18 | /** |
| 19 | * @var \phpbb\db\driver\driver_interface |
| 20 | */ |
| 21 | protected $db; |
| 22 | |
| 23 | /** |
| 24 | * @var \phpbb\event\dispatcher_interface |
| 25 | */ |
| 26 | protected $dispatcher; |
| 27 | |
| 28 | /** |
| 29 | * @var \phpbb\config\config |
| 30 | */ |
| 31 | protected $config; |
| 32 | |
| 33 | /** |
| 34 | * @var \phpbb\auth\auth |
| 35 | */ |
| 36 | protected $auth; |
| 37 | |
| 38 | /** |
| 39 | * @var \phpbb\user |
| 40 | */ |
| 41 | protected $user; |
| 42 | |
| 43 | /** |
| 44 | * @var \phpbb\notification\manager |
| 45 | */ |
| 46 | protected $notifications; |
| 47 | |
| 48 | /** |
| 49 | * @var array |
| 50 | */ |
| 51 | protected $report_data; |
| 52 | |
| 53 | /** |
| 54 | * Constructor |
| 55 | * |
| 56 | * @param \phpbb\db\driver\driver_interface $db |
| 57 | * @param \phpbb\event\dispatcher_interface $dispatcher |
| 58 | * @param \phpbb\config\config $config |
| 59 | * @param \phpbb\auth\auth $auth |
| 60 | * @param \phpbb\user $user |
| 61 | * @param \phpbb\notification\manager $notification |
| 62 | */ |
| 63 | public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\auth\auth $auth, \phpbb\user $user, \phpbb\notification\manager $notification) |
| 64 | { |
| 65 | $this->db = $db; |
| 66 | $this->dispatcher = $dispatcher; |
| 67 | $this->config = $config; |
| 68 | $this->auth = $auth; |
| 69 | $this->user = $user; |
| 70 | $this->notifications = $notification; |
| 71 | $this->report_data = array(); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Creates a report entity in the database |
| 76 | * |
| 77 | * @param array $report_data |
| 78 | * @return int the ID of the created entity |
| 79 | */ |
| 80 | protected function create_report(array $report_data) |
| 81 | { |
| 82 | $sql_ary = array( |
| 83 | 'reason_id' => (int) $report_data['reason_id'], |
| 84 | 'post_id' => $report_data['post_id'], |
| 85 | 'pm_id' => $report_data['pm_id'], |
| 86 | 'user_id' => (int) $this->user->data['user_id'], |
| 87 | 'user_notify' => (int) $report_data['user_notify'], |
| 88 | 'report_closed' => 0, |
| 89 | 'report_time' => (int) time(), |
| 90 | 'report_text' => (string) $report_data['report_text'], |
| 91 | 'reported_post_text' => $report_data['reported_post_text'], |
| 92 | 'reported_post_uid' => $report_data['reported_post_uid'], |
| 93 | 'reported_post_bitfield' => $report_data['reported_post_bitfield'], |
| 94 | 'reported_post_enable_bbcode' => $report_data['reported_post_enable_bbcode'], |
| 95 | 'reported_post_enable_smilies' => $report_data['reported_post_enable_smilies'], |
| 96 | 'reported_post_enable_magic_url' => $report_data['reported_post_enable_magic_url'], |
| 97 | ); |
| 98 | |
| 99 | $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); |
| 100 | $this->db->sql_query($sql); |
| 101 | |
| 102 | return (int) $this->db->sql_nextid(); |
| 103 | } |
| 104 | } |