|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* You may not change or alter any portion of this comment or credits |
|
4
|
|
|
* of supporting developers from this source code or any supporting source code |
|
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
* |
|
7
|
|
|
* This program is distributed in the hope that it will be useful, |
|
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
14
|
|
|
* @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
|
15
|
|
|
* @package efqdirectory |
|
16
|
|
|
* @since |
|
17
|
|
|
* @author Martijn Hertog (aka wtravel) |
|
18
|
|
|
* @author XOOPS Development Team, |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class efqListing |
|
23
|
|
|
* Manages operations for listings |
|
24
|
|
|
* |
|
25
|
|
|
* @package efqDirectory |
|
26
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
27
|
|
|
* @copyright EFQ Consultancy (c) 2007 |
|
28
|
|
|
* @version 1.1.0 |
|
29
|
|
|
*/ |
|
30
|
|
|
class efqListing extends XoopsObject |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
public $_editrights = false; |
|
33
|
|
|
public $_currentuser; |
|
34
|
|
|
public $_value = array(); |
|
35
|
|
|
public $_postdata = array(); |
|
36
|
|
|
public $_datatypes = array(); |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Constructor |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct() |
|
42
|
|
|
{ |
|
43
|
|
|
// class constructor; |
|
44
|
|
|
$this->setCurrentUser(); |
|
45
|
|
|
|
|
46
|
|
|
$this->initVar('itemid', XOBJ_DTYPE_INT, 0, true); |
|
|
|
|
|
|
47
|
|
|
$this->initVar('logourl', XOBJ_DTYPE_TXTBOX, null, false, 255); |
|
|
|
|
|
|
48
|
|
|
$this->initVar('uid', XOBJ_DTYPE_INT, 0, true); |
|
49
|
|
|
$this->initVar('status', XOBJ_DTYPE_INT, 0, true); |
|
50
|
|
|
$this->initVar('created', XOBJ_DTYPE_INT, 0, true); |
|
51
|
|
|
$this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false, 255); |
|
52
|
|
|
$this->initVar('hits', XOBJ_DTYPE_INT, 0, true); |
|
53
|
|
|
$this->initVar('rating', XOBJ_DTYPE_OTHER, 0.0, true); |
|
|
|
|
|
|
54
|
|
|
$this->initVar('votes', XOBJ_DTYPE_INT, 0, true); |
|
55
|
|
|
$this->initVar('typeid', XOBJ_DTYPE_INT, 0, true); |
|
56
|
|
|
$this->initVar('dirid', XOBJ_DTYPE_INT, 0, true); |
|
57
|
|
|
$this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Function setListingVars sets listing variables |
|
62
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
63
|
|
|
* @copyright EFQ Consultancy (c) 2007 |
|
64
|
|
|
* @version 1.0.0 |
|
65
|
|
|
* |
|
66
|
|
|
* @param array $listing Array with listing details |
|
67
|
|
|
*/ |
|
68
|
|
|
public function setListingVars($listing = array()) |
|
69
|
|
|
{ |
|
70
|
|
|
if (is_array($listing)) { |
|
71
|
|
|
$this->setVar('itemid', $listing['itemid']); |
|
72
|
|
|
$this->setVar('logourl', $listing['logourl']); |
|
73
|
|
|
$this->setVar('uid', $listing['uid']); |
|
74
|
|
|
$this->setVar('status', $listing['status']); |
|
75
|
|
|
$this->setVar('created', $listing['created']); |
|
76
|
|
|
$this->setVar('title', $listing['title']); |
|
77
|
|
|
$this->setVar('hits', $listing['hits']); |
|
78
|
|
|
$this->setVar('rating', $listing['rating']); |
|
79
|
|
|
$this->setVar('votes', $listing['votes']); |
|
80
|
|
|
$this->setVar('typeid', $listing['typeid']); |
|
81
|
|
|
$this->setVar('dirid', $listing['dirid']); |
|
82
|
|
|
$this->setVar('description', $listing['description']); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function setDataTypes($arr = array()) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->_datatypes = $arr; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function getDataTypes() |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->_datatypes; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function setCurrentUser() |
|
97
|
|
|
{ |
|
98
|
|
|
global $xoopsUser; |
|
99
|
|
|
$this->_currentuser = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function setEditRights($value = false) |
|
103
|
|
|
{ |
|
104
|
|
|
$this->_editrights = $value; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function addPostDataArray($arr) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->_postdata[] = $arr; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function updateListing() |
|
113
|
|
|
{ |
|
114
|
|
|
global $xoopsDB; |
|
115
|
|
|
// Save array _postdata into database as update; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function insertListing() |
|
119
|
|
|
{ |
|
120
|
|
|
global $xoopsDB; |
|
121
|
|
|
// Save array postdata into database as new record; |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* Class efqListingHandler |
|
127
|
|
|
* Manages database operations for listings |
|
128
|
|
|
* |
|
129
|
|
|
* @package efqDirectory |
|
130
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
131
|
|
|
* @copyright EFQ Consultancy (c) 2007 |
|
132
|
|
|
* @version 1.1.0 |
|
133
|
|
|
*/ |
|
134
|
|
|
class efqListingHandler extends XoopsObjectHandler |
|
|
|
|
|
|
135
|
|
|
{ |
|
136
|
|
|
public function __construct() |
|
137
|
|
|
{ |
|
138
|
|
|
//Instantiate class |
|
139
|
|
|
$this->db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
|
|
|
|
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* Function updateStatus updates status for listing |
|
144
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
145
|
|
|
* @copyright EFQ Consultancy (c) 2007 |
|
146
|
|
|
* @version 1.0.0 |
|
147
|
|
|
* |
|
148
|
|
|
* @param int $itemid - Default: 0 - Listing to be updated |
|
149
|
|
|
* @param int|string $newstatus - Default: '1' - New status for listing |
|
150
|
|
|
* @return bool true if update is succesful, false if unsuccesful |
|
151
|
|
|
*/ |
|
152
|
|
|
public function updateStatus($itemid = 0, $newstatus = '1') |
|
153
|
|
|
{ |
|
154
|
|
|
$sql = 'UPDATE ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . ' SET status = ' . $newstatus . ' WHERE itemid = ' . (int)$itemid . ''; |
|
|
|
|
|
|
155
|
|
|
if ($this->db->query($sql)) { |
|
156
|
|
|
return true; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
return false; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Function incrementHits increments hits for listing with 1 |
|
164
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
165
|
|
|
* @copyright EFQ Consultancy (c) 2007 |
|
166
|
|
|
* @version 1.0.0 |
|
167
|
|
|
* |
|
168
|
|
|
* @param int $itemid - Default: 0 - Listing to be updated |
|
169
|
|
|
* |
|
170
|
|
|
* @return bool true if update is succesful, false if unsuccesful |
|
171
|
|
|
*/ |
|
172
|
|
|
public function incrementHits($itemid = 0) |
|
173
|
|
|
{ |
|
174
|
|
|
$sql = sprintf('UPDATE %s SET hits = hits+1 WHERE itemid = %u AND STATUS = 2', $this->db->prefix($module->getVar('dirname', 'n') . '_items'), (int)$itemid); |
|
|
|
|
|
|
175
|
|
|
if ($this->db->queryF($sql)) { |
|
176
|
|
|
return true; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
return false; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* Function getLinkedCatsArray gets categories linked to a listing. |
|
184
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
185
|
|
|
* @copyright EFQ Consultancy (c) 2007 |
|
186
|
|
|
* @version 1.0.0 |
|
187
|
|
|
* |
|
188
|
|
|
* @param int|string $itemid - Default: '0' - Listing ID |
|
189
|
|
|
* @param int|string $dirid - Default: '0' - Directory ID |
|
190
|
|
|
* @return array $arr Array with category ID's |
|
191
|
|
|
*/ |
|
192
|
|
|
public function getLinkedCatsArray($itemid = '0', $dirid = '0') |
|
193
|
|
|
{ |
|
194
|
|
|
$sql = 'SELECT c.cid, x.active FROM ' |
|
195
|
|
|
. $this->db->prefix($module->getVar('dirname', 'n') . '_cat') |
|
|
|
|
|
|
196
|
|
|
. ' c, ' |
|
197
|
|
|
. $this->db->prefix($module->getVar('dirname', 'n') . '_item_x_cat') |
|
198
|
|
|
. ' x WHERE c.cid=x.cid AND x.itemid=' |
|
199
|
|
|
. (int)$itemid |
|
200
|
|
|
. " AND c.dirid='" |
|
201
|
|
|
. (int)$dirid |
|
202
|
|
|
. '\' AND c.active=\'1\''; |
|
203
|
|
|
$result = $this->db->query($sql); |
|
204
|
|
|
$numrows = $this->db->getRowsNum($result); |
|
205
|
|
|
$arr = array(); |
|
206
|
|
|
if ($numrows > 0) { |
|
207
|
|
|
while (list($cid, $active) = $this->db->fetchRow($result)) { |
|
208
|
|
|
$arr[] = $cid; |
|
209
|
|
|
} |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
return $arr; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* Function getListing gets listing from DB as an array. |
|
217
|
|
|
* |
|
218
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
219
|
|
|
* @copyright EFQ Consultancy (c) 2007 |
|
220
|
|
|
* @version 1.0.0 |
|
221
|
|
|
* |
|
222
|
|
|
* @param int $itemid - Default: '0' - Listing ID |
|
223
|
|
|
* |
|
224
|
|
|
* @return array $arr Array with listing fields and values |
|
225
|
|
|
*/ |
|
226
|
|
|
public function getListing($itemid) |
|
227
|
|
|
{ |
|
228
|
|
|
$sql = 'SELECT i.*, t.description FROM ' . $this->db->prefix($module->getVar('dirname', 'n') . '_items') . ' i LEFT JOIN ' . $this->db->prefix($module->getVar('dirname', 'n') . '_item_text') . ' t ON (i.itemid=t.itemid) WHERE i.itemid=' . (int)$itemid; |
|
|
|
|
|
|
229
|
|
|
$result = $this->db->query($sql); |
|
230
|
|
|
$arr = array(); |
|
231
|
|
|
if (!$result) { |
|
232
|
|
|
return $arr; |
|
233
|
|
|
} else { |
|
234
|
|
|
$numrows = $this->db->getRowsNum($result); |
|
235
|
|
|
if ($numrows == 0) { |
|
236
|
|
|
return $arr; |
|
237
|
|
|
} else { |
|
238
|
|
|
$arr = $this->db->fetchArray($result); |
|
239
|
|
|
} |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
return $arr; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
public function getDataTypes($itemid) |
|
246
|
|
|
{ |
|
247
|
|
|
global $datafieldmanager; |
|
248
|
|
|
$sql = 'SELECT DISTINCT t.dtypeid, t.title, t.section, t.icon, f.typeid, f.fieldtype, f.ext, t.options, t.custom, d.itemid, d.value, d.customtitle '; |
|
249
|
|
|
$sql .= 'FROM ' |
|
250
|
|
|
. $this->db->prefix($module->getVar('dirname', 'n') . '_item_x_cat') |
|
|
|
|
|
|
251
|
|
|
. ' ic, ' |
|
252
|
|
|
. $this->db->prefix($module->getVar('dirname', 'n') . '_dtypes_x_cat') |
|
253
|
|
|
. ' xc, ' |
|
254
|
|
|
. $this->db->prefix($module->getVar('dirname', 'n') . '_fieldtypes') |
|
255
|
|
|
. ' f, ' |
|
256
|
|
|
. $this->db->prefix($module->getVar('dirname', 'n') . '_dtypes') |
|
257
|
|
|
. ' t '; |
|
258
|
|
|
$sql .= 'LEFT JOIN ' . $this->db->prefix($module->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . (int)$itemid . ') '; |
|
259
|
|
|
$sql .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . (int)$itemid . ' ORDER BY t.seq ASC'; |
|
260
|
|
|
$result = $this->db->query($sql); |
|
261
|
|
|
$numrows = $this->db->getRowsNum($result); |
|
|
|
|
|
|
262
|
|
|
//$arr = $this->db->fetchArray($result); |
|
|
|
|
|
|
263
|
|
|
$arr = array(); |
|
264
|
|
View Code Duplication |
while (list($dtypeid, $title, $section, $icon, $ftypeid, $fieldtype, $ext, $options, $custom, $itemid, $value, $customtitle) = $this->db->fetchRow($result)) { |
|
|
|
|
|
|
265
|
|
|
$fieldvalue = $datafieldmanager->getFieldValue($fieldtype, $options, $value); |
|
266
|
|
|
if ($icon != '') { |
|
267
|
|
|
$iconurl = "<img src=\"uploads/$icon\">"; |
|
268
|
|
|
} else { |
|
269
|
|
|
$iconurl = ''; |
|
270
|
|
|
} |
|
271
|
|
|
if ($custom != '0' && $customtitle != '') { |
|
272
|
|
|
$title = $customtitle; |
|
273
|
|
|
} |
|
274
|
|
|
$arr[] = array( |
|
275
|
|
|
'dtypeid' => $dtypeid, |
|
276
|
|
|
'title' => $title, |
|
277
|
|
|
'section' => $section, |
|
278
|
|
|
'icon' => $iconurl, |
|
279
|
|
|
'ftypeid' => $ftypeid, |
|
280
|
|
|
'fieldtype' => $fieldtype, |
|
281
|
|
|
'ext' => $ext, |
|
282
|
|
|
'options' => $options, |
|
283
|
|
|
'custom' => $custom, |
|
284
|
|
|
'itemid' => $itemid, |
|
285
|
|
|
'value' => $fieldvalue, |
|
286
|
|
|
'customtitle' => $customtitle |
|
287
|
|
|
); |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
|
return $arr; |
|
291
|
|
|
} |
|
292
|
|
|
} |
|
293
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths