1
|
|
|
<?php |
|
|
|
|
2
|
|
|
require_once __DIR__ . '/wizard.php'; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Class CheckoutWizard |
6
|
|
|
*/ |
7
|
|
|
class CheckoutWizard extends ZervWizard |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* checkoutwizard constructor. |
11
|
|
|
*/ |
12
|
|
|
public function __construct() |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
global $field; |
|
|
|
|
15
|
|
|
// start the session and initialize the wizard |
16
|
|
|
if (!isset($_SESSION)) { |
17
|
|
|
session_start(); |
18
|
|
|
} |
19
|
|
|
parent::__construct($_SESSION, __CLASS__); |
20
|
|
|
|
21
|
|
|
$this->addStep('Fieldname', _MA_PEDIGREE_ENTER_FIELD); |
22
|
|
|
if ($this->getValue('field') == 0) { //only for a new field |
23
|
|
|
$this->addStep('Fieldtype', _MA_PEDIGREE_FIELD_TYP_SEL); |
24
|
|
|
if ($this->getValue('fieldtype') === 'selectbox' || $this->getValue('fieldtype') === 'radiobutton') { |
25
|
|
|
$this->addStep('lookup', _MA_PEDIGREE_FIELD_ADD_VALUE); |
26
|
|
|
} |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
$this->addStep('Settings', _MA_PEDIGREE_FIELD_PARAM); |
30
|
|
|
if ($this->getValue('hassearch') === 'hassearch') { |
31
|
|
|
$this->addStep('search', _MA_PEDIGREE_SEARCH_PARAMFIELD); |
32
|
|
|
} |
33
|
|
|
if ($this->getValue('fieldtype') !== 'picture') { |
34
|
|
|
$this->addStep('defaultvalue', _MA_PEDIGREE_FIELD_DEFAUT); |
35
|
|
|
} |
36
|
|
|
$this->addStep('confirm', _MA_PEDIGREE_FIELDCONFIRM); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function prepareFieldname() |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
global $field; |
|
|
|
|
42
|
|
|
if (!$field == 0) { |
43
|
|
|
// field allready exists (editing mode) |
44
|
|
|
|
45
|
|
|
$sql = 'SELECT * from ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . ' WHERE ID=' . $field; |
46
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
47
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
48
|
|
|
$name = $row['FieldName']; |
49
|
|
|
$fieldexplanation = $row['FieldExplanation']; |
50
|
|
|
$fieldtype = $row['FieldType']; |
51
|
|
|
} |
52
|
|
|
$this->setValue('name', $name); |
|
|
|
|
53
|
|
|
$this->setValue('explain', $fieldexplanation); |
|
|
|
|
54
|
|
|
//set the fieldtype because we wont allow it to be edited |
55
|
|
|
$this->setValue('fieldtype', $fieldtype); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
$this->setValue('field', $field); //is it a new field or are we editing a field |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param $form |
62
|
|
|
* |
63
|
|
|
* @return bool |
64
|
|
|
*/ |
65
|
|
|
public function processFieldname(&$form) |
66
|
|
|
{ |
67
|
|
|
$name = $this->coalesce($form['name']); |
68
|
|
|
if (strlen($name) > 0) { |
69
|
|
|
$this->setValue('name', $name); |
70
|
|
|
} else { |
71
|
|
|
$this->addError('name', _MA_PEDIGREE_FIELD_NAM); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
$fieldexplanation = $this->coalesce($form['explain']); |
75
|
|
|
if (strlen($fieldexplanation) > 0) { |
76
|
|
|
$this->setValue('explain', $fieldexplanation); |
77
|
|
|
} else { |
78
|
|
|
$this->addError('explain', _MA_PEDIGREE_FIELD_EXPLAN1); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return !$this->isError(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function prepareFieldtype() |
85
|
|
|
{ |
86
|
|
|
$this->fieldtype[] = array('value' => 'radiobutton', 'description' => _MA_PEDIGREE_RADIOBUTTONFIELD); |
|
|
|
|
87
|
|
|
$this->fieldtype[] = array('value' => 'selectbox', 'description' => _MA_PEDIGREE_DROPDOWNFIELD); |
88
|
|
|
$this->fieldtype[] = array('value' => 'textbox', 'description' => _MA_PEDIGREE_TEXTBOXFIELD); |
89
|
|
|
$this->fieldtype[] = array('value' => 'textarea', 'description' => _MA_PEDIGREE_TEXTAREAFIELD); |
90
|
|
|
$this->fieldtype[] = array('value' => 'DataSelect', 'description' => _MA_PEDIGREE_DATEFIELD); |
91
|
|
|
$this->fieldtype[] = array('value' => 'urlfield', 'description' => _MA_PEDIGREE_URLFIELD); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param $form |
96
|
|
|
* |
97
|
|
|
* @return bool |
98
|
|
|
*/ |
99
|
|
|
public function processFieldtype($form) |
100
|
|
|
{ |
101
|
|
|
$this->prepareFieldtype(); |
102
|
|
|
$fieldtype = $this->coalesce($form['fieldtype']); |
103
|
|
|
$this->setValue('fieldtype', $fieldtype); |
104
|
|
|
|
105
|
|
|
return !$this->isError(); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param $form |
110
|
|
|
* |
111
|
|
|
* @return bool |
112
|
|
|
*/ |
113
|
|
|
public function processLookup($form) |
114
|
|
|
{ |
115
|
|
|
$fc = $this->coalesce($form['fc']); |
116
|
|
|
$this->setValue('fc', $fc); |
117
|
|
|
$lookup = $this->coalesce($form['lookup' . $fc]); |
118
|
|
|
$lookupid = $this->coalesce($form['id' . $fc]); |
119
|
|
|
if (strlen($lookup) > 0) { |
120
|
|
|
$this->setValue('lookup' . $fc, $lookup); |
121
|
|
|
$this->setValue('id' . $fc, $lookupid); |
122
|
|
|
} |
123
|
|
|
$lastlookup = $this->getValue('lookup' . $fc); |
124
|
|
|
if ($lastlookup == '') { |
125
|
|
|
$this->setValue('fc', $fc - 1); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
for ($i = 0; $i < $fc; ++$i) { |
129
|
|
|
$radioarray[] = array('id' => $this->getValue('id' . ($i + 1)), 'value' => $this->getValue('lookup' . ($i + 1))); |
|
|
|
|
130
|
|
|
} |
131
|
|
|
//print_r($radioarray); die(); |
|
|
|
|
132
|
|
|
$this->setValue('radioarray', $radioarray); |
|
|
|
|
133
|
|
|
|
134
|
|
|
return !$this->isError(); |
135
|
|
|
// |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function prepareSettings() |
|
|
|
|
139
|
|
|
{ |
140
|
|
|
if (!$this->getValue('field') == 0) { |
141
|
|
|
// field allready exists (editing mode) |
142
|
|
|
|
143
|
|
|
{ |
144
|
|
|
$sql = 'SELECT * from ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . " WHERE ID='" . $this->getValue('field') . "'"; |
145
|
|
|
} |
146
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
147
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
148
|
|
|
$hs = $row['HasSearch']; |
149
|
|
|
if ($hs == '1') { |
150
|
|
|
$this->setValue('hassearch', 'hassearch'); |
151
|
|
|
} |
152
|
|
|
$vip = $row['ViewInPedigree']; |
153
|
|
|
if ($vip == '1') { |
154
|
|
|
$this->setValue('viewinpedigree', 'viewinpedigree'); |
155
|
|
|
} |
156
|
|
|
$via = $row['ViewInAdvanced']; |
157
|
|
|
if ($via == '1') { |
158
|
|
|
$this->setValue('viewinadvanced', 'viewinadvanced'); |
159
|
|
|
} |
160
|
|
|
$vipie = $row['ViewInPie']; |
161
|
|
|
if ($vipie == '1') { |
162
|
|
|
$this->setValue('viewinpie', 'viewinpie'); |
163
|
|
|
} |
164
|
|
|
$vil = $row['ViewInList']; |
165
|
|
|
if ($vil == '1') { |
166
|
|
|
$this->setValue('viewinlist', 'viewinlist'); |
167
|
|
|
} |
168
|
|
|
$lit = $row['Litter']; |
169
|
|
|
if ($lit == '1') { |
170
|
|
|
$this->setValue('Litter', 'Litter'); |
171
|
|
|
} |
172
|
|
|
$Glit = $row['Generallitter']; |
173
|
|
|
if ($Glit == '1') { |
174
|
|
|
$this->setValue('Generallitter', 'Generallitter'); |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @param $form |
182
|
|
|
* |
183
|
|
|
* @return bool |
184
|
|
|
*/ |
185
|
|
|
public function processSettings($form) |
186
|
|
|
{ |
187
|
|
|
$hassearch = $this->coalesce($form['hassearch']); |
188
|
|
|
$this->setValue('hassearch', $hassearch); |
189
|
|
|
$viewinpedigree = $this->coalesce($form['viewinpedigree']); |
190
|
|
|
$this->setValue('viewinpedigree', $viewinpedigree); |
191
|
|
|
$viewinadvanced = $this->coalesce($form['viewinadvanced']); |
192
|
|
|
$this->setValue('viewinadvanced', $viewinadvanced); |
193
|
|
|
$viewinpie = $this->coalesce($form['viewinpie']); |
194
|
|
|
$this->setValue('viewinpie', $viewinpie); |
195
|
|
|
$viewinlist = $this->coalesce($form['viewinlist']); |
196
|
|
|
$this->setValue('viewinlist', $viewinlist); |
197
|
|
|
$Litter = $this->coalesce($form['Litter']); |
198
|
|
|
$this->setValue('Litter', $Litter); |
199
|
|
|
$Generallitter = $this->coalesce($form['Generallitter']); |
200
|
|
|
$this->setValue('Generallitter', $Generallitter); |
201
|
|
|
|
202
|
|
|
//if both litter and general litter are set; unset one of them |
203
|
|
|
if ($this->getValue('Litter') === 'Litter' && $this->getValue('Generallitter') === 'Generallitter') { |
204
|
|
|
$this->setValue('Generallitter', 0); |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
return !$this->isError(); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
public function prepareSearch() |
|
|
|
|
211
|
|
|
{ |
212
|
|
|
if (!$this->getValue('field') == 0) { |
213
|
|
|
// field allready exists (editing mode) |
214
|
|
|
|
215
|
|
|
$sql = 'SELECT * from ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . ' WHERE ID=' . $this->getValue('field'); |
216
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
217
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
218
|
|
|
if ($this->getValue('hassearch') === 'hassearch') { |
219
|
|
|
$searchname = $row['SearchName']; |
220
|
|
|
$this->setValue('searchname', $searchname); |
221
|
|
|
$searchexplain = $row['SearchExplanation']; |
222
|
|
|
$this->setValue('searchexplain', $searchexplain); |
223
|
|
|
} |
224
|
|
|
} |
225
|
|
|
} |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param $form |
230
|
|
|
* |
231
|
|
|
* @return bool |
232
|
|
|
*/ |
233
|
|
|
public function processSearch($form) |
234
|
|
|
{ |
235
|
|
|
$searchname = $this->coalesce($form['searchname']); |
236
|
|
|
if (strlen($searchname) > 0) { |
237
|
|
|
$this->setValue('searchname', $searchname); |
238
|
|
|
} else { |
239
|
|
|
$this->addError('searchname', 'Please enter the searchname'); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
$fieldexplanation = $this->coalesce($form['searchexplain']); |
243
|
|
|
if (strlen($fieldexplanation) > 0) { |
244
|
|
|
$this->setValue('searchexplain', $fieldexplanation); |
245
|
|
|
} else { |
246
|
|
|
$this->addError('searchexplain', 'Please enter the search explanation for this field'); |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
return !$this->isError(); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
public function prepareDefaultvalue() |
|
|
|
|
253
|
|
|
{ |
254
|
|
|
if (!$this->getValue('field') == 0) { |
255
|
|
|
// field allready exists (editing mode) |
256
|
|
|
|
257
|
|
|
$sql = 'SELECT * from ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . ' WHERE ID=' . $this->getValue('field'); |
258
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
259
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
260
|
|
|
$def = $row['DefaultValue']; |
261
|
|
|
$this->setValue('defaultvalue', $def); |
262
|
|
|
if ($row['LookupTable'] == '1') { //we have a lookup table; load values |
263
|
|
|
$sql = 'SELECT * from ' . $GLOBALS['xoopsDB']->prefix('pedigree_lookup' . $this->getValue('field')) . " order by 'order'"; |
264
|
|
|
$fc = 0; |
265
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
266
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
267
|
|
|
$radioarray[] = array('id' => $row['Id'], 'value' => $row['value']); |
|
|
|
|
268
|
|
|
++$fc; |
269
|
|
|
} |
270
|
|
|
$this->setValue('radioarray', $radioarray); |
|
|
|
|
271
|
|
|
$this->setValue('fc', $fc); |
272
|
|
|
} |
273
|
|
|
} |
274
|
|
|
} |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* @param $form |
279
|
|
|
* |
280
|
|
|
* @return bool |
281
|
|
|
*/ |
282
|
|
|
public function processDefaultValue($form) |
283
|
|
|
{ |
284
|
|
|
$defaultvalue = $this->coalesce($form['defaultvalue']); |
285
|
|
|
if (strlen($defaultvalue) >= 0) { |
286
|
|
|
$this->setValue('defaultvalue', $defaultvalue); |
287
|
|
|
} else { |
288
|
|
|
$this->addError('defaultvalue', 'Please enter a defaultvalue'); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
return !$this->isError(); |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* @param $form |
296
|
|
|
* |
297
|
|
|
* @return bool |
298
|
|
|
*/ |
299
|
|
|
public function processConfirm($form) |
|
|
|
|
300
|
|
|
{ |
301
|
|
|
return !$this->isError(); |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
public function completeCallback() |
|
|
|
|
305
|
|
|
{ |
306
|
|
|
|
307
|
|
|
//can this field be searched |
308
|
|
|
$search = $this->getValue('hassearch'); |
309
|
|
|
if ($search === 'hassearch') { |
310
|
|
|
$search = '1'; |
311
|
|
|
$searchname = $this->getValue('searchname'); |
312
|
|
|
$searchexplain = $this->getValue('searchexplain'); |
313
|
|
|
} else { |
314
|
|
|
$search = '0'; |
315
|
|
|
$searchname = ''; |
316
|
|
|
$searchexplain = ''; |
317
|
|
|
} |
318
|
|
|
//show in pedigree |
319
|
|
|
$viewinpedigree = $this->getValue('viewinpedigree'); |
320
|
|
|
if ($viewinpedigree === 'viewinpedigree') { |
321
|
|
|
$viewinpedigree = '1'; |
322
|
|
|
} else { |
323
|
|
|
$viewinpedigree = '0'; |
324
|
|
|
} |
325
|
|
|
//show in advanced |
326
|
|
|
$viewinadvanced = $this->getValue('viewinadvanced'); |
327
|
|
|
if ($viewinadvanced === 'viewinadvanced') { |
328
|
|
|
$viewinadvanced = '1'; |
329
|
|
|
} else { |
330
|
|
|
$viewinadvanced = '0'; |
331
|
|
|
} |
332
|
|
|
//show in pie |
333
|
|
|
$viewinpie = $this->getValue('viewinpie'); |
334
|
|
|
if ($viewinpie === 'viewinpie') { |
335
|
|
|
$viewinpie = '1'; |
336
|
|
|
} else { |
337
|
|
|
$viewinpie = '0'; |
338
|
|
|
} |
339
|
|
|
//view in list |
340
|
|
|
$viewinlist = $this->getValue('viewinlist'); |
341
|
|
|
if ($viewinlist === 'viewinlist') { |
342
|
|
|
$viewinlist = '1'; |
343
|
|
|
} else { |
344
|
|
|
$viewinlist = '0'; |
345
|
|
|
} |
346
|
|
|
//add a litter |
347
|
|
|
$Litter = $this->getValue('Litter'); |
348
|
|
|
if ($Litter === 'Litter') { |
349
|
|
|
$Litter = '1'; |
350
|
|
|
} else { |
351
|
|
|
$Litter = '0'; |
352
|
|
|
} |
353
|
|
|
//general litter |
354
|
|
|
$Generallitter = $this->getValue('Generallitter'); |
355
|
|
|
if ($Generallitter === 'Generallitter') { |
356
|
|
|
$Generallitter = '1'; |
357
|
|
|
} else { |
358
|
|
|
$Generallitter = '0'; |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
if (!$this->getValue('field') == 0) { |
362
|
|
|
// field allready exists (editing mode) |
363
|
|
|
|
364
|
|
|
$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . " SET fieldName = '" . htmlspecialchars($this->getValue('name')) . "', fieldType = '" . $this->getValue('fieldType') . "', defaultValue = '" . $this->getValue('defaultValue') . "', fieldExplanation = '" . $this->getValue('explain') . "', hasSearch = '" . $search . "', Litter = '" . $litter . "', generallitter = '" . $generallitter . "', searchName = '" . $searchname . "', searchExplanation = '" . $searchexplain . "', viewInPedigree = '" . $viewinpedigree . "', viewInAdvanced = '" . $viewinadvanced . "', viewInPie = '" . $viewinpie . "', viewInList = '" . $viewinlist . "' WHERE ID ='" . $this->getValue('field') . "'"; |
|
|
|
|
365
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
366
|
|
|
//possible change defaultvalue for userfield |
367
|
|
|
$sql = 'ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' CHANGE `user' . $this->getValue('field') . '` `user' . $this->getValue('field') . "` VARCHAR( 255 ) NOT NULL DEFAULT '" . $this->getValue('defaultvalue') . "'"; |
368
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
369
|
|
|
$sql = 'ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('pedigree_temp') . ' CHANGE `user' . $this->getValue('field') . '` `user' . $this->getValue('field') . "` VARCHAR( 1024 ) NOT NULL DEFAULT '" . $this->getValue('defaultvalue') . "'"; |
370
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
371
|
|
|
$sql = 'ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash') . ' CHANGE `user' . $this->getValue('field') . '` `user' . $this->getValue('field') . "` VARCHAR( 255 ) NOT NULL DEFAULT '" . $this->getValue('defaultvalue') . "'"; |
372
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
373
|
|
|
} else { //this is a new field |
374
|
|
|
$sql = 'SELECT MAX(ID) AS lid from ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . ' LIMIT 1'; |
375
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
376
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
377
|
|
|
$nextfieldnum = $row['lid'] + 1; |
378
|
|
|
} |
379
|
|
|
//add userfield to various tables as a new field. |
380
|
|
|
//allways add at the end of the table |
381
|
|
|
$tables = array('pedigree_tree', 'pedigree_temp', 'pedigree_trash'); |
382
|
|
|
foreach ($tables as $table) { |
383
|
|
|
$SQL = 'ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix($table) . ' ADD `user' . $nextfieldnum . "` VARCHAR( 255 ) NOT NULL DEFAULT '" . $this->getValue('defaultvalue') . "'"; |
|
|
|
|
384
|
|
|
$GLOBALS['xoopsDB']->queryF($SQL); |
385
|
|
|
} |
386
|
|
|
//is a lookup table present |
387
|
|
|
$lookup = $this->getValue('lookup1'); |
388
|
|
|
if ($lookup == '') { |
389
|
|
|
$lookup = '0'; |
390
|
|
|
} else { |
391
|
|
|
$lookup = '1'; |
392
|
|
|
//create table for lookupfield |
393
|
|
|
$createtable = 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('pedigree_lookup' . $nextfieldnum) . ' (`ID` INT( 10 ) NOT NULL ,`value` VARCHAR( 255 ) NOT NULL, `order` INT( 10 )) ENGINE = MyISAM'; |
394
|
|
|
$GLOBALS['xoopsDB']->queryF($createtable); |
395
|
|
|
//fill table |
396
|
|
|
$count = $this->getValue('fc'); |
397
|
|
|
for ($x = 1; $x < $count + 1; ++$x) { |
398
|
|
|
$y = $x - 1; |
399
|
|
|
$sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('pedigree_lookup' . $nextfieldnum) . " ( `ID` , `value`, `order`) VALUES ('" . $y . "', '" . $this->getValue('lookup' . $x) . "','" . $y . "')"; |
400
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
401
|
|
|
} |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
//Insert new record into pedigree_config |
405
|
|
|
// $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . " VALUES ('" . $nextfieldnum . "', '1', '" . htmlspecialchars($this->getValue('name')) . "', '" . $this->getValue('fieldtype') . "', '" . $lookup . "', '" . $this->getValue('defaultvalue') . "', '" . $this->getValue('explain') . "', '" . $search . "', '" . $Litter . "', '" . $Generallitter . "', '" . $searchname . "', '" . $searchexplain . "', '" . $viewinpedigree . "', '" . $viewinadvanced . "', '" . $viewinpie . "', '" . $viewinlist . "','','" . $nextfieldnum . "')"; |
|
|
|
|
406
|
|
|
$sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . " VALUES ('" . $nextfieldnum . "', '1', '" . $GLOBALS['xoopsDB']->escape(htmlSpecialChars($this->getValue('name'))) . "', '" . $GLOBALS['xoopsDB']->escape($this->getValue('fieldtype')) . "', '" . $GLOBALS['xoopsDB']->escape($lookup) . "', '" . $GLOBALS['xoopsDB']->escape($this->getValue('defaultvalue')) . "', '" . $GLOBALS['xoopsDB']->escape($this->getValue('explain')) . "', '" . $GLOBALS['xoopsDB']->escape($search) . "', '" . $GLOBALS['xoopsDB']->escape($Litter) . "', '" . $GLOBALS['xoopsDB']->escape($Generallitter) . "', '" . $GLOBALS['xoopsDB']->escape($searchname) . "', '" . $GLOBALS['xoopsDB']->escape($searchexplain) . "', '" . $GLOBALS['xoopsDB']->escape($viewinpedigree) . "', '" . $GLOBALS['xoopsDB']->escape($viewinadvanced) . "', '" . $GLOBALS['xoopsDB']->escape($viewinpie) . "', '" . $GLOBALS['xoopsDB']->escape($viewinlist) . "','','" . $GLOBALS['xoopsDB']->escape($nextfieldnum) . "')"; |
407
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
408
|
|
|
} |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* Miscellaneous utility functions |
413
|
|
|
* |
414
|
|
|
* @param $email |
415
|
|
|
* |
416
|
|
|
* @return int |
417
|
|
|
*/ |
418
|
|
|
|
419
|
|
|
public function isValidEmail($email) |
420
|
|
|
{ |
421
|
|
|
return preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/i', $email); |
422
|
|
|
} |
423
|
|
|
} |
424
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.