1
|
|
|
<?php |
2
|
|
|
// $Id: listing.php,v 1.1.0 2007/11/03 17:46:00 wtravel |
3
|
|
|
// ------------------------------------------------------------------------ // |
4
|
|
|
// EFQ Directory // |
5
|
|
|
// Copyright (c) 2006 EFQ Consultancy // |
6
|
|
|
// <http://www.efqdirectory.com/> // |
7
|
|
|
// ------------------------------------------------------------------------ // |
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
11
|
|
|
// (at your option) any later version. // |
12
|
|
|
// // |
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
14
|
|
|
// of supporting developers from this source code or any supporting // |
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
16
|
|
|
// original comment or credit authors. // |
17
|
|
|
// // |
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
21
|
|
|
// GNU General Public License for more details. // |
22
|
|
|
// // |
23
|
|
|
// You should have received a copy of the GNU General Public License // |
24
|
|
|
// along with this program; if not, write to the Free Software // |
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
26
|
|
|
// ------------------------------------------------------------------------ // |
27
|
|
|
// Part of the efqDirectory module provided by: wtravel // |
28
|
|
|
// e-mail: [email protected] // |
29
|
|
|
// Purpose: Create a business directory for xoops. // |
30
|
|
|
// Based upon the mylinks and the mxDirectory modules // |
31
|
|
|
// ------------------------------------------------------------------------- // |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Class efqListing |
35
|
|
|
* Manages operations for listings |
36
|
|
|
* |
37
|
|
|
* @package efqDirectory |
38
|
|
|
* @author EFQ Consultancy <[email protected]> |
39
|
|
|
* @copyright EFQ Consultancy (c) 2007 |
40
|
|
|
* @version 1.1.0 |
41
|
|
|
*/ |
42
|
|
|
class efqListingData extends XoopsObject |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
public $_updated = false; |
45
|
|
|
public $_inserted = false; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Constructor |
49
|
|
|
*/ |
50
|
|
|
public function __construct() |
51
|
|
|
{ |
52
|
|
|
// class constructor; |
53
|
|
|
//$this->setCurrentUser(); |
|
|
|
|
54
|
|
|
$this->initVar('dataid', XOBJ_DTYPE_INT, 0, true); |
|
|
|
|
55
|
|
|
$this->initVar('itemid', XOBJ_DTYPE_INT, 0, true); |
56
|
|
|
$this->initVar('dtypeid', XOBJ_DTYPE_INT, 0, true); |
57
|
|
|
$this->initVar('itemid', XOBJ_DTYPE_INT, 0, true); |
58
|
|
|
$this->initVar('value', XOBJ_DTYPE_TXTAREA, null, false); |
|
|
|
|
59
|
|
|
$this->initVar('created', XOBJ_DTYPE_INT, 0, true); |
60
|
|
|
$this->initVar('customtitle', XOBJ_DTYPE_TXTBOX, null, false, 255); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
//Set variable $_updated to true of false (default) |
|
|
|
|
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param bool $set |
67
|
|
|
*/ |
68
|
|
|
public function setUpdated($set = false) |
69
|
|
|
{ |
70
|
|
|
$this->_updated = $set; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
//Set variable $_inserted to true of false (default) |
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param bool $set |
77
|
|
|
*/ |
78
|
|
|
public function setInserted($set = false) |
79
|
|
|
{ |
80
|
|
|
$this->_inserted = $set; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param $arr |
85
|
|
|
* @return bool |
86
|
|
|
*/ |
87
|
|
View Code Duplication |
public function setListingData($arr) |
|
|
|
|
88
|
|
|
{ |
89
|
|
|
if (is_array($arr)) { |
90
|
|
|
$vars = $this->getVars(); |
91
|
|
|
foreach ($vars as $k => $v) { |
92
|
|
|
$this->setVar($k, $arr[$k]); |
93
|
|
|
} |
94
|
|
|
} else { |
95
|
|
|
return false; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
return true; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Class efqListingHandler |
104
|
|
|
* Manages database operations for listings |
105
|
|
|
* |
106
|
|
|
* @package efqDirectory |
107
|
|
|
* @author EFQ Consultancy <[email protected]> |
108
|
|
|
* @copyright EFQ Consultancy (c) 2007 |
109
|
|
|
* @version 1.1.0 |
110
|
|
|
*/ |
111
|
|
|
class efqListingDataHandler extends XoopsObjectHandler |
|
|
|
|
112
|
|
|
{ |
113
|
|
|
public $errorhandler; |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* efqListingDataHandler constructor. |
117
|
|
|
*/ |
118
|
|
|
public function __construct() |
119
|
|
|
{ |
120
|
|
|
//Instantiate class |
121
|
|
|
global $eh; |
122
|
|
|
$this->db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
|
|
|
123
|
|
|
$this->errorhandler = $eh; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param int $itemid |
128
|
|
|
* @return array |
129
|
|
|
*/ |
130
|
|
|
public function getData($itemid = 0) |
131
|
|
|
{ |
132
|
|
|
$arr = array(); |
133
|
|
|
$sql = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.dataid, d.itemid, d.value, d.created, t.custom '; |
134
|
|
|
$sql .= 'FROM ' . $this->db->prefix('efqdiralpha1_item_x_cat') . ' ic, ' . $this->db->prefix('efqdiralpha1_dtypes_x_cat') . ' xc, ' . $this->db->prefix('efqdiralpha1_fieldtypes') . ' f, ' . $this->db->prefix('efqdiralpha1_dtypes') . ' t '; |
135
|
|
|
$sql .= 'LEFT JOIN ' . $this->db->prefix('efqdiralpha1_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $itemid . ') '; |
136
|
|
|
$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=" . $itemid . ''; |
137
|
|
|
$data_result = $this->db->query($sql) or $eh->show('0013'); |
|
|
|
|
138
|
|
|
while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $dataid, $itemid, $value, $created, $custom) = $this->db->fetchRow($data_result)) { |
139
|
|
|
$arr[] = array( |
140
|
|
|
'dtypeid' => $dtypeid, |
141
|
|
|
'title' => $title, |
142
|
|
|
'section' => $section, |
143
|
|
|
'ftypeid' => $ftypeid, |
144
|
|
|
'fieldtype' => $fieldtype, |
145
|
|
|
'ext' => $ext, |
146
|
|
|
'options' => $options, |
147
|
|
|
'dataid' => $dataid, |
148
|
|
|
'itemid' => $itemid, |
149
|
|
|
'value' => $value, |
150
|
|
|
'created' => $created, |
151
|
|
|
'customtitle' => $custom |
152
|
|
|
); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
return $arr; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Function updateListingData updates listing data |
160
|
|
|
* @author EFQ Consultancy <[email protected]> |
161
|
|
|
* @copyright EFQ Consultancy (c) 2008 |
162
|
|
|
* @version 1.0.0 |
163
|
|
|
* |
164
|
|
|
* @param object $obj object of type listing |
165
|
|
|
* |
166
|
|
|
* @param bool $forceQuery |
167
|
|
|
* @return bool true if update is successful, false if unsuccessful |
168
|
|
|
*/ |
169
|
|
View Code Duplication |
public function updateListingData($obj, $forceQuery = false) |
|
|
|
|
170
|
|
|
{ |
171
|
|
|
$tablename = 'efqdiralpha1_data'; |
172
|
|
|
$keyName = 'dataid'; |
173
|
|
|
if ($obj instanceof efqListingData) { |
174
|
|
|
// Variable part of this function ends. From this line you can copy |
175
|
|
|
// this function for similar object handling functions. |
176
|
|
|
$obj->cleanVars(); |
177
|
|
|
$cleanvars = $obj->cleanVars; |
178
|
|
|
$keyValue = $obj->getVar($keyName); |
179
|
|
|
} else { |
180
|
|
|
return false; |
181
|
|
|
} |
182
|
|
|
$countVars = count($cleanvars); |
183
|
|
|
$i = 1; |
184
|
|
|
$strSet = ''; |
185
|
|
|
$strValues = ''; |
|
|
|
|
186
|
|
|
foreach ($cleanvars as $k => $v) { |
187
|
|
|
$strSet .= $k . '=' . "'" . $v . "'"; |
188
|
|
|
if ($i < $countVars) { |
189
|
|
|
$strSet .= ', '; |
190
|
|
|
} |
191
|
|
|
$i++; |
192
|
|
|
} |
193
|
|
|
$sql = sprintf('UPDATE %s SET %s WHERE %s = %u', $this->db->prefix($tablename), $strSet, $keyName, $keyValue); |
194
|
|
|
if ($forceQuery) { |
195
|
|
|
if ($this->db->queryF($sql)) { |
196
|
|
|
return true; |
197
|
|
|
} |
198
|
|
|
} else { |
199
|
|
|
if ($this->db->query($sql)) { |
200
|
|
|
return true; |
201
|
|
|
} |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
return false; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Function insertListingData inserts listing data into DB |
209
|
|
|
* @author EFQ Consultancy <[email protected]> |
210
|
|
|
* @copyright EFQ Consultancy (c) 2008 |
211
|
|
|
* @version 1.0.0 |
212
|
|
|
* |
213
|
|
|
* @param $obj |
214
|
|
|
* @param bool $forceQuery |
215
|
|
|
* @return bool true if insertion is succesful, false if unsuccesful |
216
|
|
|
* @internal param object $objListing object of type listing |
217
|
|
|
*/ |
218
|
|
View Code Duplication |
public function insertListingData($obj, $forceQuery = false) |
|
|
|
|
219
|
|
|
{ |
220
|
|
|
$tablename = 'efqdiralpha1_data'; |
221
|
|
|
$keyName = 'dataid'; |
222
|
|
|
if ($obj instanceof efqListingData) { |
223
|
|
|
// Variable part of this function ends. From this line you can copy |
224
|
|
|
// this function for similar object handling functions. |
225
|
|
|
$obj->cleanVars(); |
226
|
|
|
$cleanvars = $obj->cleanVars; |
227
|
|
|
} else { |
228
|
|
|
return false; |
229
|
|
|
} |
230
|
|
|
$countVars = count($cleanvars); |
231
|
|
|
$i = 1; |
232
|
|
|
$strFields = ''; |
233
|
|
|
$strValues = ''; |
234
|
|
|
foreach ($cleanvars as $k => $v) { |
235
|
|
|
$strFields .= $k; |
236
|
|
|
$strValues .= "'" . $v . "'"; |
237
|
|
|
if ($i < $countVars) { |
238
|
|
|
$strFields .= ', '; |
239
|
|
|
$strValues .= ', '; |
240
|
|
|
} |
241
|
|
|
$i++; |
242
|
|
|
} |
243
|
|
|
$sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->db->prefix($tablename), $strFields, $strValues); |
244
|
|
|
if ($forceQuery) { |
245
|
|
|
if ($this->db->queryF($sql)) { |
246
|
|
|
$itemid = $this->db->getInsertId(); |
247
|
|
|
$obj->setVar($keyName, $itemid); |
248
|
|
|
|
249
|
|
|
return true; |
250
|
|
|
} |
251
|
|
|
} else { |
252
|
|
|
if ($this->db->query($sql)) { |
253
|
|
|
$itemid = $this->db->getInsertId(); |
254
|
|
|
$obj->setVar($keyName, $itemid); |
255
|
|
|
|
256
|
|
|
return true; |
257
|
|
|
} |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
return false; |
261
|
|
|
} |
262
|
|
|
} |
263
|
|
|
|
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