This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php declare(strict_types=1); |
||
2 | |||
3 | namespace XoopsModules\Xhelp; |
||
4 | |||
5 | /* |
||
6 | * You may not change or alter any portion of this comment or credits |
||
7 | * of supporting developers from this source code or any supporting source code |
||
8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
9 | * |
||
10 | * This program is distributed in the hope that it will be useful, |
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
13 | */ |
||
14 | |||
15 | /** |
||
16 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
17 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
18 | * @author Eric Juden <[email protected]> |
||
19 | * @author XOOPS Development Team |
||
20 | */ |
||
21 | |||
22 | if (!\defined('XHELP_CLASS_PATH')) { |
||
23 | exit(); |
||
24 | } |
||
25 | // require_once XHELP_CLASS_PATH . '/BaseObjectHandler.php'; |
||
26 | |||
27 | /** |
||
28 | * SavedSearchHandler class |
||
29 | * |
||
30 | * SavedSearch Handler for SavedSearch class |
||
31 | * |
||
32 | * @author Eric Juden <[email protected]> & |
||
33 | */ |
||
34 | class SavedSearchHandler extends BaseObjectHandler |
||
35 | { |
||
36 | /** |
||
37 | * Name of child class |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | public $classname = SavedSearch::class; |
||
42 | /** |
||
43 | * DB table name |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | public $dbtable = 'xhelp_saved_searches'; |
||
48 | |||
49 | private const TABLE = 'xhelp_saved_searches'; |
||
50 | private const ENTITY = SavedSearch::class; |
||
51 | private const ENTITYNAME = 'SavedSearch'; |
||
52 | private const KEYNAME = 'id'; |
||
53 | private const IDENTIFIER = 'name'; |
||
54 | |||
55 | /** |
||
56 | * Constructor |
||
57 | * |
||
58 | * @param \XoopsMySQLDatabase|null $db reference to a xoopsDB object |
||
59 | */ |
||
60 | public function __construct(\XoopsMySQLDatabase $db = null) |
||
61 | { |
||
62 | $this->init($db); |
||
63 | $this->helper = Helper::getInstance(); |
||
64 | parent::__construct($db, static::TABLE, static::ENTITY, static::KEYNAME, static::IDENTIFIER); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param \XoopsObject $object |
||
69 | * @return string |
||
70 | */ |
||
71 | public function insertQuery(\XoopsObject $object): string |
||
72 | { |
||
73 | //TODO mb replace with individual variables |
||
74 | // Copy all object vars into local variables |
||
75 | foreach ($object->cleanVars as $k => $v) { |
||
76 | ${$k} = $v; |
||
77 | } |
||
78 | |||
79 | $sql = \sprintf('INSERT INTO `%s` (id, uid, NAME, search, pagenav_vars, hasCustFields) VALUES (%u, %d, %s, %s, %s, %u)', $this->db->prefix($this->dbtable), $id, $uid, $this->db->quoteString($name), $this->db->quoteString($search), $this->db->quoteString($pagenav_vars), $hasCustFields); |
||
80 | |||
81 | return $sql; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @param \XoopsObject $object |
||
86 | * @return string |
||
87 | */ |
||
88 | public function updateQuery(\XoopsObject $object): string |
||
89 | { |
||
90 | //TODO mb replace with individual variables |
||
91 | // Copy all object vars into local variables |
||
92 | foreach ($object->cleanVars as $k => $v) { |
||
93 | ${$k} = $v; |
||
94 | } |
||
95 | |||
96 | $sql = \sprintf('UPDATE `%s` SET uid = %d, NAME = %s, search = %s, pagenav_vars = %s, hasCustFields = %u WHERE id = %u', $this->db->prefix($this->dbtable), $uid, $this->db->quoteString($name), $this->db->quoteString($search), $this->db->quoteString($pagenav_vars), $hasCustFields, $id); |
||
97 | |||
98 | return $sql; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * @param \XoopsObject $object |
||
103 | * @return string |
||
104 | */ |
||
105 | public function deleteQuery(\XoopsObject $object): string |
||
106 | { |
||
107 | $sql = \sprintf('DELETE FROM `%s` WHERE id = %u', $this->db->prefix($this->dbtable), $object->getVar('id')); |
||
108 | |||
109 | return $sql; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @param int $uid |
||
114 | * @param bool $has_global |
||
115 | * @return array |
||
116 | */ |
||
117 | public function getByUid(int $uid, bool $has_global = false): array |
||
118 | { |
||
119 | $uid = $uid; |
||
120 | if ($has_global) { |
||
121 | $criteria = new \CriteriaCompo(new \Criteria('uid', $uid), 'OR'); |
||
122 | $criteria->add(new \Criteria('uid', \XHELP_GLOBAL_UID), 'OR'); |
||
123 | } else { |
||
124 | $criteria = new \Criteria('uid', $uid); |
||
125 | } |
||
126 | $criteria->setOrder('ASC'); |
||
127 | $criteria->setSort('name'); |
||
128 | $ret = $this->getObjects($criteria); |
||
129 | |||
130 | return $ret; |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * @param \CriteriaElement|\CriteriaCompo $criteria |
||
135 | * @return string |
||
136 | */ |
||
137 | public function createSQL($criteria): string |
||
138 | { |
||
139 | $sql = $this->selectQuery($criteria); |
||
140 | |||
141 | return $sql; |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * delete department matching a set of conditions |
||
146 | * |
||
147 | * @param \CriteriaElement|\CriteriaCompo|null $criteria {@link \CriteriaElement} |
||
148 | * @return bool FALSE if deletion failed |
||
149 | */ |
||
150 | public function deleteAll(\CriteriaElement $criteria = null, $force = true, $asObject = false): bool |
||
151 | { |
||
152 | $sql = 'DELETE FROM ' . $this->db->prefix($this->dbtable); |
||
153 | if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) { |
||
154 | $sql .= ' ' . $criteria->renderWhere(); |
||
155 | } |
||
156 | if (!$result = $this->db->query($sql)) { |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
157 | return false; |
||
158 | } |
||
159 | |||
160 | return true; |
||
161 | } |
||
162 | } |
||
163 |