|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
// ID: class.offer.php 30-apr-2007 13:39:01 efqconsultancy |
|
4
|
|
|
// ------------------------------------------------------------------------ // |
|
5
|
|
|
// EFQ Directory // |
|
6
|
|
|
// Copyright (c) 2006 EFQ Consultancy // |
|
7
|
|
|
// <http://www.efqdirectory.com/> // |
|
8
|
|
|
// ------------------------------------------------------------------------ // |
|
9
|
|
|
// This program is free software; you can redistribute it and/or modify // |
|
10
|
|
|
// it under the terms of the GNU General Public License as published by // |
|
11
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
|
12
|
|
|
// (at your option) any later version. // |
|
13
|
|
|
// // |
|
14
|
|
|
// You may not change or alter any portion of this comment or credits // |
|
15
|
|
|
// of supporting developers from this source code or any supporting // |
|
16
|
|
|
// source code which is considered copyrighted (c) material of the // |
|
17
|
|
|
// original comment or credit authors. // |
|
18
|
|
|
// // |
|
19
|
|
|
// This program is distributed in the hope that it will be useful, // |
|
20
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
21
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
22
|
|
|
// GNU General Public License for more details. // |
|
23
|
|
|
// // |
|
24
|
|
|
// You should have received a copy of the GNU General Public License // |
|
25
|
|
|
// along with this program; if not, write to the Free Software // |
|
26
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|
27
|
|
|
// ------------------------------------------------------------------------ // |
|
28
|
|
|
// Part of the efqDirectory module provided by: wtravel // |
|
29
|
|
|
// e-mail: [email protected] // |
|
30
|
|
|
// Purpose: Create a business directory for xoops. // |
|
31
|
|
|
// Based upon the mylinks and the mxDirectory modules // |
|
32
|
|
|
// ------------------------------------------------------------------------- // |
|
33
|
|
|
*/ |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Class efqXdirHandler |
|
37
|
|
|
* Manages database operations for migration from the xDirectory module |
|
38
|
|
|
* |
|
39
|
|
|
* @package efqDirectory |
|
40
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
41
|
|
|
* @copyright EFQ Consultancy (c) 2007 |
|
42
|
|
|
* @version 1.1.0 |
|
43
|
|
|
*/ |
|
44
|
|
|
class efqXdirHandler extends XoopsObjectHandler |
|
|
|
|
|
|
45
|
|
|
{ |
|
46
|
|
|
// public $db; //Database reference |
|
|
|
|
|
|
47
|
|
|
public $objXdir; |
|
48
|
|
|
public $errors; //array(); |
|
49
|
|
|
public $categories; //array(); |
|
50
|
|
|
public $listings; //array(); |
|
51
|
|
|
public $xdir_cats; //array(); |
|
52
|
|
|
public $efq_dirid; |
|
53
|
|
|
public $fieldtypes; //array(); |
|
54
|
|
|
public $datatypes; //array(); |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* efqSubscriptionOfferHandler::efqItemTypeHandler() |
|
58
|
|
|
* |
|
59
|
|
|
*/ |
|
60
|
|
|
public function __construct() |
|
61
|
|
|
{ |
|
62
|
|
|
$this->db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param $arr |
|
67
|
|
|
*/ |
|
68
|
|
|
public function set_xdir_cats($arr) |
|
69
|
|
|
{ |
|
70
|
|
|
if (is_array($arr)) { |
|
71
|
|
|
$this->xdir_cats = $arr; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return mixed |
|
77
|
|
|
*/ |
|
78
|
|
|
public function get_xdir_cats() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->xdir_cats; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return mixed |
|
85
|
|
|
*/ |
|
86
|
|
|
public function get_errors() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->errors; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* getCategories_xdir() |
|
93
|
|
|
* |
|
94
|
|
|
* Get xdir categories from database and return |
|
95
|
|
|
* |
|
96
|
|
|
* @return \arr|bool |
|
97
|
|
|
*/ |
|
98
|
|
|
public function setCategories_xdir() |
|
99
|
|
|
{ |
|
100
|
|
|
$arr = array(); |
|
101
|
|
|
$sql = 'SELECT cid, pid, title, imgurl FROM ' . $this->db->prefix('efqdiralpha1_xdir_cat'); |
|
102
|
|
|
$result = $this->db->query($sql); |
|
103
|
|
|
if (!$result) { |
|
104
|
|
|
return false; |
|
105
|
|
|
} |
|
106
|
|
|
$numrows = $this->db->getRowsNum($result); |
|
107
|
|
|
if ($numrows > 0) { |
|
108
|
|
View Code Duplication |
while (list($cid, $pid, $title, $imgurl) = $this->db->fetchRow($result)) { |
|
|
|
|
|
|
109
|
|
|
$arr[] = array('cid' => $cid, 'pid' => $pid, 'title' => $title, 'imgurl' => $imgurl); |
|
110
|
|
|
} |
|
111
|
|
|
} else { |
|
112
|
|
|
return false; |
|
113
|
|
|
} |
|
114
|
|
|
$this->set_xdir_cats($arr); |
|
115
|
|
|
|
|
116
|
|
|
return true; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param int $dirid |
|
121
|
|
|
* @return bool |
|
122
|
|
|
*/ |
|
123
|
|
|
public function saveCategories($dirid = 0) |
|
124
|
|
|
{ |
|
125
|
|
|
$tablename = 'efqdiralpha1_cat'; |
|
126
|
|
|
$xdir_cats = $this->get_xdir_cats(); |
|
127
|
|
|
foreach ($xdir_cats as $xdir_cat) { |
|
128
|
|
|
$cid = $xdir_cat['cid']; |
|
129
|
|
|
$pid = $xdir_cat['pid']; |
|
130
|
|
|
$title = $xdir_cat['title']; |
|
131
|
|
|
$imgurl = $xdir_cat['imgurl']; |
|
132
|
|
|
//Set fields and values |
|
133
|
|
|
$strFields = 'cid,dirid,title,active,pid,img,allowlist'; |
|
134
|
|
|
$strValues = "$cid,$dirid,'$title',1,$pid,'$imgurl',1"; |
|
135
|
|
|
$sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->db->prefix($tablename), $strFields, $strValues); |
|
136
|
|
|
if ($this->db->queryF($sql)) { |
|
137
|
|
|
$itemid = $this->db->getInsertId(); |
|
138
|
|
|
$obj->setVar($keyName, $itemid); |
|
|
|
|
|
|
139
|
|
|
|
|
140
|
|
|
return true; |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Function createDataTypes inserts datatypes into DB |
|
147
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
148
|
|
|
* @copyright EFQ Consultancy (c) 2008 |
|
149
|
|
|
* @version 1.0.0 |
|
150
|
|
|
* @return bool true if insertion is succesful, false if unsuccesful |
|
151
|
|
|
* @internal param object $obj object |
|
152
|
|
|
* |
|
153
|
|
|
*/ |
|
154
|
|
|
public function createDataTypes() |
|
155
|
|
|
{ |
|
156
|
|
|
$datatypeHandler = new efqDataTypeHandler(); |
|
157
|
|
|
$arr[] = array('title' => _MD_XDIR_DTYPE_ADDRESS, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX); |
|
|
|
|
|
|
158
|
|
|
$arr[] = array('title' => _MD_XDIR_DTYPE_ADDRESS2, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX); |
|
|
|
|
|
|
159
|
|
|
$arr[] = array('title' => _MD_XDIR_DTYPE_CITY, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX); |
|
|
|
|
|
|
160
|
|
|
$arr[] = array('title' => _MD_XDIR_DTYPE_STATE, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX); |
|
|
|
|
|
|
161
|
|
|
$arr[] = array('title' => _MD_XDIR_DTYPE_ZIP, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX); |
|
|
|
|
|
|
162
|
|
|
$arr[] = array('title' => _MD_XDIR_DTYPE_COUNTRY, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX); |
|
|
|
|
|
|
163
|
|
|
$arr[] = array('title' => _MD_XDIR_DTYPE_PHONE, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX); |
|
|
|
|
|
|
164
|
|
|
$arr[] = array('title' => _MD_XDIR_DTYPE_FAX, 'fieldtype' => _MD_XDIR_FIELDTYPE_TEXTBOX); |
|
|
|
|
|
|
165
|
|
|
$arr[] = array('title' => _MD_XDIR_DTYPE_EMAIL, 'fieldtype' => _MD_XDIR_FIELDTYPE_EMAIL); |
|
|
|
|
|
|
166
|
|
|
$arr[] = array('title' => _MD_XDIR_DTYPE_URL, 'fieldtype' => _MD_XDIR_FIELDTYPE_URL); |
|
|
|
|
|
|
167
|
|
|
foreach ($arr as $datatype) { |
|
168
|
|
|
$objDataType = new efqFieldType; |
|
169
|
|
|
$objDataType->setVar('title', $datatype['title']); |
|
170
|
|
|
$objDataType->setVar('section', 0); |
|
171
|
|
|
$objDataType->setVar('uid', $xoopsUser->getVar('uid')); |
|
|
|
|
|
|
172
|
|
|
$objDataType->setVar('defaultyn', 1); |
|
173
|
|
|
$objDataType->setVar('created', time()); |
|
174
|
|
|
$objDataType->setVar('activeyn', 1); |
|
175
|
|
|
$objDataType->setVar('fieldtypeid', $this->fieldtypes[$datatype['fieldtype']]); |
|
176
|
|
|
$datatypeHandler->insertDataType($objDataType, true); |
|
177
|
|
|
$datatypes[$datatype['title']] = $objDataType->getVar('dtypeid'); |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Function createFieldTypes inserts field types into DB |
|
183
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
184
|
|
|
* @copyright EFQ Consultancy (c) 2008 |
|
185
|
|
|
* @version 1.0.0 |
|
186
|
|
|
* @return bool true if insertion is succesful, false if unsuccesful |
|
187
|
|
|
* @internal param object $obj object |
|
188
|
|
|
* |
|
189
|
|
|
*/ |
|
190
|
|
|
public function createFieldTypes() |
|
191
|
|
|
{ |
|
192
|
|
|
$fieldtypeHandler = new efqFieldTypeHandler(); |
|
193
|
|
|
$arr[] = array('title' => _MD_XDIR_FIELDTYPE_TEXTBOX, 'fieldtype' => 'textbox'); |
|
|
|
|
|
|
194
|
|
|
$arr[] = array('title' => _MD_XDIR_FIELDTYPE_EMAIL, 'fieldtype' => 'email'); |
|
|
|
|
|
|
195
|
|
|
$arr[] = array('title' => _MD_XDIR_FIELDTYPE_URL, 'fieldtype' => 'url'); |
|
|
|
|
|
|
196
|
|
|
foreach ($arr as $fieldtype) { |
|
197
|
|
|
$objFieldtype = new efqFieldType; |
|
198
|
|
|
$objFieldtype->setVar('title', $fieldtype['title']); |
|
199
|
|
|
$objFieldtype->setVar('fieldtype', $fieldtype['fieldtype']); |
|
200
|
|
|
$objFieldtype->setVar('dirid', $this->efq_dirid); |
|
201
|
|
|
$fieldtypeHandler->insertFieldType($objFieldtype, true); |
|
202
|
|
|
$fieldtypes[$fieldtype['title']] = $objFieldtype->getVar('typeid'); |
|
203
|
|
|
} |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Function doMigrate migrates xDirectory to EFQ Directory |
|
208
|
|
|
* @author EFQ Consultancy <[email protected]> |
|
209
|
|
|
* @copyright EFQ Consultancy (c) 2008 |
|
210
|
|
|
* @version 1.0.0 |
|
211
|
|
|
* |
|
212
|
|
|
* @param int $dirid |
|
213
|
|
|
* @return bool true if insertion is succesful, false if unsuccesful |
|
214
|
|
|
* @internal param object $obj object |
|
215
|
|
|
* |
|
216
|
|
|
*/ |
|
217
|
|
|
public function doMigrate($dirid = 0) |
|
218
|
|
|
{ |
|
219
|
|
|
$this->setCategories_xdir(); |
|
220
|
|
|
$this->saveCategories($this->efq_dirid); |
|
221
|
|
|
$this->createFieldTypes(); |
|
222
|
|
|
$this->createDataTypes(); |
|
223
|
|
|
} |
|
224
|
|
|
} |
|
225
|
|
|
|
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