These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php namespace XoopsModules\Newbb; |
||
2 | |||
3 | /** |
||
4 | * NewBB 5.0x, the forum module for XOOPS project |
||
5 | * |
||
6 | * @copyright XOOPS Project (https://xoops.org) |
||
7 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
8 | * @author Taiwen Jiang (phppp or D.J.) <[email protected]> |
||
9 | * @since 4.00 |
||
10 | * @package module::newbb |
||
11 | */ |
||
12 | |||
13 | // defined('XOOPS_ROOT_PATH') || exit('Restricted access.'); |
||
14 | |||
15 | defined('NEWBB_FUNCTIONS_INI') || include $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); |
||
16 | |||
17 | /** |
||
18 | * Class ReportHandler |
||
19 | */ |
||
20 | class ReportHandler extends \XoopsPersistableObjectHandler |
||
21 | { |
||
22 | /** |
||
23 | * @param \XoopsDatabase $db |
||
24 | */ |
||
25 | public function __construct(\XoopsDatabase $db) |
||
26 | { |
||
27 | parent::__construct($db, 'newbb_report', Report::class, 'report_id', ''); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param $posts |
||
32 | * @return array |
||
33 | */ |
||
34 | public function getByPost($posts) |
||
35 | { |
||
36 | $ret = []; |
||
37 | if (!$posts) { |
||
38 | return $ret; |
||
39 | } |
||
40 | if (!is_array($posts)) { |
||
41 | $posts = [$posts]; |
||
42 | } |
||
43 | $post_criteria = new \Criteria('post_id', '(' . implode(', ', $posts) . ')', 'IN'); |
||
44 | $ret = $this->getAll($post_criteria); |
||
45 | |||
46 | return $ret; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @param int $forums |
||
51 | * @param string $order |
||
52 | * @param int $perpage |
||
53 | * @param $start |
||
54 | * @param int $report_result |
||
55 | * @param int $report_id |
||
56 | * @return array |
||
57 | */ |
||
58 | public function getAllReports( |
||
59 | $forums = 0, |
||
60 | $order = 'ASC', |
||
61 | $perpage = 0, |
||
62 | &$start, |
||
63 | $report_result = 0, |
||
64 | $report_id = 0 |
||
0 ignored issues
–
show
|
|||
65 | ) { |
||
66 | $forumCriteria = ''; |
||
67 | $row = []; |
||
68 | if ('DESC' === $order) { |
||
69 | $operator_for_position = '>'; |
||
70 | } else { |
||
71 | $order = 'ASC'; |
||
72 | $operator_for_position = '<'; |
||
73 | } |
||
74 | $order_criteria = " ORDER BY r.report_id $order"; |
||
75 | |||
76 | if ($perpage <= 0) { |
||
77 | $perpage = 10; |
||
78 | } |
||
79 | if (empty($start)) { |
||
80 | $start = 0; |
||
81 | } |
||
82 | $result_criteria = ' AND r.report_result = ' . $report_result; |
||
83 | |||
84 | if ($forums) { |
||
85 | $forumCriteria = ''; |
||
86 | } elseif (!is_array($forums)) { |
||
87 | $forums = [$forums]; |
||
88 | $forumCriteria = ' AND p.forum_id IN (' . implode(',', $forums) . ')'; |
||
89 | } |
||
90 | $tables_criteria = ' FROM ' . $this->db->prefix('newbb_report') . ' r, ' . $this->db->prefix('newbb_posts') . ' p WHERE r.post_id= p.post_id'; |
||
91 | |||
92 | if ($report_id) { |
||
93 | $result = $this->db->query('SELECT COUNT(*) as report_count' . $tables_criteria . $forumCriteria . $result_criteria . " AND report_id $operator_for_position $report_id" . $order_criteria); |
||
94 | if ($result) { |
||
95 | $row = $this->db->fetchArray($result); |
||
96 | } |
||
97 | $position = $row['report_count']; |
||
98 | $start = (int)($position / $perpage) * $perpage; |
||
99 | } |
||
100 | |||
101 | $sql = 'SELECT r.*, p.subject, p.topic_id, p.forum_id' . $tables_criteria . $forumCriteria . $result_criteria . $order_criteria; |
||
102 | $result = $this->db->query($sql, $perpage, $start); |
||
103 | $ret = []; |
||
104 | //$reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); |
||
105 | while ($myrow = $this->db->fetchArray($result)) { |
||
106 | $ret[] = $myrow; // return as array |
||
107 | } |
||
108 | |||
109 | return $ret; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * |
||
114 | */ |
||
115 | public function synchronization() |
||
116 | { |
||
117 | // return; |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * clean orphan items from database |
||
122 | * |
||
123 | * @param string $table_link |
||
124 | * @param string $field_link |
||
125 | * @param string $field_object |
||
126 | * @return bool true on success |
||
127 | */ |
||
128 | public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() |
||
129 | { |
||
130 | return parent::cleanOrphan($this->db->prefix('newbb_posts'), 'post_id'); |
||
131 | } |
||
132 | } |
||
133 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.