1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder\Files; |
4
|
|
|
|
5
|
|
|
use XoopsModules\Modulebuilder; |
6
|
|
|
use XoopsModules\Modulebuilder\Constants; |
7
|
|
|
|
8
|
|
|
/* |
9
|
|
|
You may not change or alter any portion of this comment or credits |
10
|
|
|
of supporting developers from this source code or any supporting source code |
11
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
12
|
|
|
|
13
|
|
|
This program is distributed in the hope that it will be useful, |
14
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16
|
|
|
*/ |
17
|
|
|
/** |
18
|
|
|
* modulebuilder module. |
19
|
|
|
* |
20
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
21
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
22
|
|
|
* |
23
|
|
|
* @since 2.5.0 |
24
|
|
|
* |
25
|
|
|
* @author Txmod Xoops https://xoops.org |
26
|
|
|
* Goffy https://myxoops.org |
27
|
|
|
* |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
//require \dirname(__DIR__) . '/autoload.php'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Class CheckData. |
34
|
|
|
*/ |
35
|
|
|
class CheckData |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* @var mixed |
39
|
|
|
*/ |
40
|
|
|
private $cf = null; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var mixed |
44
|
|
|
*/ |
45
|
|
|
private $modId = null; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var mixed |
49
|
|
|
*/ |
50
|
|
|
private $tables = null; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var mixed |
54
|
|
|
*/ |
55
|
|
|
private $infos = []; |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @public function constructor |
61
|
|
|
* @param null |
62
|
|
|
*/ |
63
|
|
|
public function __construct() |
64
|
|
|
{ |
65
|
|
|
$this->cf = Modulebuilder\Files\CreateFile::getInstance(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @static function getInstance |
70
|
|
|
* |
71
|
|
|
* @param null |
72
|
|
|
* |
73
|
|
|
* @return Modulebuilder\Files\CheckData |
74
|
|
|
*/ |
75
|
|
|
public static function getInstance() |
76
|
|
|
{ |
77
|
|
|
static $instance = false; |
78
|
|
|
if (!$instance) { |
79
|
|
|
$instance = new self(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $instance; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @public function getCheckResult |
87
|
|
|
* |
88
|
|
|
* @param $module |
89
|
|
|
* @return array |
90
|
|
|
*/ |
91
|
|
|
public function getCheckPreBuilding($module) |
92
|
|
|
{ |
93
|
|
|
$this->modId = $module->getVar('mod_id'); |
94
|
|
|
$this->tables = $this->cf->getTableTables($this->modId); |
95
|
|
|
$this->infos = []; |
96
|
|
|
|
97
|
|
|
$this->getCheckBlock(); |
98
|
|
|
$this->getCheckBroken(); |
99
|
|
|
$this->getCheckComments(); |
100
|
|
|
$this->getCheckUserpage(); |
101
|
|
|
$this->getCheckRating(); |
102
|
|
|
$this->getCheckReads(); |
103
|
|
|
$this->getCheckSQL(); |
104
|
|
|
|
105
|
|
|
return $this->infos; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @public function getCheckBroken |
110
|
|
|
* |
111
|
|
|
* @return array|bool |
112
|
|
|
*/ |
113
|
|
|
private function getCheckBroken() |
114
|
|
|
{ |
115
|
|
|
foreach (\array_keys($this->tables) as $t) { |
116
|
|
|
if (1 == $this->tables[$t]->getVar('table_broken')) { |
117
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
118
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
119
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
120
|
|
|
$fieldSatus = ''; |
121
|
|
|
|
122
|
|
|
foreach (\array_keys($fields) as $f) { |
123
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
124
|
|
|
if (Constants::FIELD_ELE_SELECTSTATUS == $fields[$f]->getVar('field_element')) { |
125
|
|
|
$fieldSatus = $fieldName; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
// check whether each table with handling "broken" has also a field "status" |
129
|
|
|
if ('' == $fieldSatus) { |
130
|
|
|
$info = \str_replace('%t', $tableName, \_AM_MODULEBUILDER_BUILDING_CHECK_BROKEN1); |
131
|
|
|
$this->infos[] = ['icon' => 'error', 'info' => $info]; |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
return true; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @private function getCheckUserpage |
141
|
|
|
* |
142
|
|
|
* @return array|bool |
143
|
|
|
*/ |
144
|
|
|
private function getCheckUserpage() |
145
|
|
|
{ |
146
|
|
|
//check field params: minimum one param is selected |
147
|
|
|
foreach (\array_keys($this->tables) as $t) { |
148
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
149
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
150
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
151
|
|
|
|
152
|
|
|
foreach (\array_keys($fields) as $f) { |
153
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
154
|
|
|
// check fields for parameters |
155
|
|
|
if ($f > 0) { |
156
|
|
|
$fieldParams = (int)$fields[$f]->getVar('field_parent') + (int)$fields[$f]->getVar('field_admin') + (int)$fields[$f]->getVar('field_inlist') + (int)$fields[$f]->getVar('field_inform') |
157
|
|
|
+ (int)$fields[$f]->getVar('field_user') + (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot') |
158
|
|
|
+ (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot') + (int)$fields[$f]->getVar('field_block') |
159
|
|
|
+ (int)$fields[$f]->getVar('field_main') + (int)$fields[$f]->getVar('field_search') + (int)$fields[$f]->getVar('field_required'); |
160
|
|
|
if (0 == $fieldParams) { |
161
|
|
|
$info = \str_replace(['%f', '%t'], [$fieldName, $tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_FIELDS1); |
162
|
|
|
$this->infos[] = ['icon' => 'error', 'info' => $info]; |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
//check field params: user file no usage in index or item |
169
|
|
|
foreach (\array_keys($this->tables) as $t) { |
170
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
171
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
172
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
173
|
|
|
|
174
|
|
|
foreach (\array_keys($fields) as $f) { |
175
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
176
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
177
|
|
|
// check fields for parameters |
178
|
|
|
if ($f > 0) { |
179
|
|
|
$fieldParams = (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot') |
180
|
|
|
+ (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot'); |
181
|
|
|
if (0 == $fieldParams) { |
182
|
|
|
$info = \str_replace(['%f', '%t'], [$fieldName, $tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_FIELDS2); |
183
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
} |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
//check field params: user file index multiple usage |
190
|
|
|
//check field params: user file item multiple usage |
191
|
|
|
foreach (\array_keys($this->tables) as $t) { |
192
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
193
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
194
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
195
|
|
|
|
196
|
|
|
foreach (\array_keys($fields) as $f) { |
197
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
198
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
199
|
|
|
// check fields for parameters |
200
|
|
|
if ($f > 0) { |
201
|
|
|
$fieldParams = (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot'); |
202
|
|
|
if ($fieldParams > 1) { |
203
|
|
|
$info = \str_replace(['%f', '%t'], [$fieldName, $tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_FIELDS3); |
204
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
205
|
|
|
} |
206
|
|
|
$fieldParams = (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot'); |
207
|
|
|
if ($fieldParams > 1) { |
208
|
|
|
$info = \str_replace(['%f', '%t'], [$fieldName, $tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_FIELDS3); |
209
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
210
|
|
|
} |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
} |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
//check table params: user submit or rate or broken, but table not for user side |
217
|
|
|
foreach (\array_keys($this->tables) as $t) { |
218
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
219
|
|
|
if ((0 == $this->tables[$t]->getVar('table_user')) && (1 == $this->tables[$t]->getVar('table_submit') || 1 == $this->tables[$t]->getVar('table_broken') || 1 == $this->tables[$t]->getVar('table_rate'))) { |
220
|
|
|
$info = \str_replace(['%t'], [$tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_USERPAGE1); |
221
|
|
|
$this->infos[] = ['icon' => 'error', 'info' => $info]; |
222
|
|
|
} |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
//check field/table params: params for index file, but table param table_index = 0 |
226
|
|
|
//check field/table params: params for user file, but table param table_user = 0 |
227
|
|
|
foreach (\array_keys($this->tables) as $t) { |
228
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
229
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
230
|
|
|
$tableIndex = (int)$this->tables[$t]->getVar('table_index'); |
231
|
|
|
$tableUser = (int)$this->tables[$t]->getVar('table_user'); |
232
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
233
|
|
|
|
234
|
|
|
$fieldParamsIndex = 0; |
235
|
|
|
$fieldParamsUser = 0; |
236
|
|
|
$fieldName = ''; |
237
|
|
|
foreach (\array_keys($fields) as $f) { |
238
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
239
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
240
|
|
|
// check fields for parameters |
241
|
|
|
if ($f > 0) { |
242
|
|
|
$fieldParams = (int)$fields[$f]->getVar('field_ihead') + (int)$fields[$f]->getVar('field_ibody') + (int)$fields[$f]->getVar('field_ifoot'); |
243
|
|
|
$fieldParamsIndex += $fieldParams; |
244
|
|
|
if ($fieldParams >= 1 && 0 == $tableIndex) { |
245
|
|
|
$info = \str_replace(['%f', '%t'], [$fieldName, $tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_FIELDS5); |
246
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
247
|
|
|
} |
248
|
|
|
$fieldParams = (int)$fields[$f]->getVar('field_thead') + (int)$fields[$f]->getVar('field_tbody') + (int)$fields[$f]->getVar('field_tfoot'); |
249
|
|
|
$fieldParamsUser += $fieldParams; |
250
|
|
|
if ($fieldParams >= 1 && 0 == $tableUser) { |
251
|
|
|
$info = \str_replace(['%f', '%t'], [$fieldName, $tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_FIELDS7); |
252
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
253
|
|
|
} |
254
|
|
|
} |
255
|
|
|
} |
256
|
|
|
} |
257
|
|
|
if (0 == $fieldParamsIndex && 1 == $tableIndex) { |
258
|
|
|
$info = \str_replace(['%f', '%t'], [$fieldName, $tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_FIELDS4); |
259
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
260
|
|
|
} |
261
|
|
|
if (0 == $fieldParamsUser && 1 == $tableUser) { |
262
|
|
|
$info = \str_replace(['%f', '%t'], [$fieldName, $tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_FIELDS6); |
263
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
264
|
|
|
} |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
return true; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* @private function getCheckBlock |
272
|
|
|
* |
273
|
|
|
* @return array|bool |
274
|
|
|
*/ |
275
|
|
|
private function getCheckBlock() |
276
|
|
|
{ |
277
|
|
|
//use in block but no field selected |
278
|
|
|
foreach (\array_keys($this->tables) as $t) { |
279
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
280
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
281
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
282
|
|
|
$count = 0; |
283
|
|
|
if (1 == $this->tables[$t]->getVar('table_blocks')) { |
284
|
|
|
foreach (\array_keys($fields) as $f) { |
285
|
|
|
if (1 == $fields[$f]->getVar('field_block')) { |
286
|
|
|
$count++; |
287
|
|
|
} |
288
|
|
|
} |
289
|
|
|
if (0 == $count) { |
290
|
|
|
$info = \str_replace(['%t'], [$tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_BLOCK1); |
291
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
292
|
|
|
} |
293
|
|
|
} |
294
|
|
|
} |
295
|
|
|
//use in block but no field date |
296
|
|
|
foreach (\array_keys($this->tables) as $t) { |
297
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
298
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
299
|
|
|
|
300
|
|
|
$count = 0; |
301
|
|
|
if (1 == $this->tables[$t]->getVar('table_blocks')) { |
302
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
303
|
|
|
foreach (\array_keys($fields) as $f) { |
304
|
|
|
if (Constants::FIELD_ELE_TEXTDATESELECT == $fields[$f]->getVar('field_element') || Constants::FIELD_ELE_DATETIME == $fields[$f]->getVar('field_element')) { |
305
|
|
|
$count++; |
306
|
|
|
} |
307
|
|
|
} |
308
|
|
|
if (0 == $count) { |
309
|
|
|
$info = \str_replace(['%t'], [$tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_BLOCK2); |
310
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
311
|
|
|
} |
312
|
|
|
} |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
return true; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* @private function getCheckComments |
320
|
|
|
* |
321
|
|
|
* @return array|bool |
322
|
|
|
*/ |
323
|
|
|
private function getCheckComments() |
324
|
|
|
{ |
325
|
|
|
//use comments in multiple tables |
326
|
|
|
$count = 0; |
327
|
|
|
$tableComments = []; |
328
|
|
|
foreach (\array_keys($this->tables) as $t) { |
329
|
|
|
if (1 == $this->tables[$t]->getVar('table_comments')) { |
330
|
|
|
$count++; |
331
|
|
|
$tableComments[] = $this->tables[$t]->getVar('table_name'); |
332
|
|
|
} |
333
|
|
|
} |
334
|
|
|
if ($count > 1) { |
335
|
|
|
$tablesComments = \implode(', ', $tableComments); |
336
|
|
|
$info = \str_replace('%t', $tablesComments, \_AM_MODULEBUILDER_BUILDING_CHECK_COMMENTS1); |
337
|
|
|
$this->infos[] = ['icon' => 'error', 'info' => $info]; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
foreach (\array_keys($this->tables) as $t) { |
341
|
|
|
if (1 == $this->tables[$t]->getVar('table_comments')) { |
342
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
343
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
344
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
345
|
|
|
$fieldComments = 0; |
346
|
|
|
foreach (\array_keys($fields) as $f) { |
347
|
|
|
if (Constants::FIELD_ELE_TEXTCOMMENTS == (int)$fields[$f]->getVar('field_element')) { |
348
|
|
|
$fieldComments++; |
349
|
|
|
} |
350
|
|
|
} |
351
|
|
|
// check whether each table with handling "comments" has also a field "comments" |
352
|
|
|
if (0 == $fieldComments) { |
353
|
|
|
$info = \str_replace('%t', $tableName, \_AM_MODULEBUILDER_BUILDING_CHECK_COMMENTS2); |
354
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
355
|
|
|
} |
356
|
|
|
} |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
return true; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
/** |
363
|
|
|
* @private function getCheckRatings |
364
|
|
|
* |
365
|
|
|
* @return array|bool |
366
|
|
|
*/ |
367
|
|
|
private function getCheckRating() |
368
|
|
|
{ |
369
|
|
|
foreach (\array_keys($this->tables) as $t) { |
370
|
|
|
if (1 == $this->tables[$t]->getVar('table_rate')) { |
371
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
372
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
373
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
374
|
|
|
$fieldRatings = 0; |
375
|
|
|
$fieldVotes = 0; |
376
|
|
|
foreach (\array_keys($fields) as $f) { |
377
|
|
|
if (Constants::FIELD_ELE_TEXTRATINGS == (int)$fields[$f]->getVar('field_element')) { |
378
|
|
|
$fieldRatings++; |
379
|
|
|
} |
380
|
|
|
if (Constants::FIELD_ELE_TEXTVOTES == (int)$fields[$f]->getVar('field_element')) { |
381
|
|
|
$fieldVotes++; |
382
|
|
|
} |
383
|
|
|
} |
384
|
|
|
// check whether each table with handling "rating" has also a field "rating" |
385
|
|
|
if (0 == (int)$fieldRatings) { |
386
|
|
|
$info = \str_replace('%t', $tableName, \_AM_MODULEBUILDER_BUILDING_CHECK_RATINGS1); |
387
|
|
|
$this->infos[] = ['icon' => 'error', 'info' => $info]; |
388
|
|
|
} |
389
|
|
|
// check whether each table with handling "rating" has also a field "votes" |
390
|
|
|
if (0 == (int)$fieldVotes) { |
391
|
|
|
$info = \str_replace('%t', $tableName, \_AM_MODULEBUILDER_BUILDING_CHECK_RATINGS2); |
392
|
|
|
$this->infos[] = ['icon' => 'error', 'info' => $info]; |
393
|
|
|
} |
394
|
|
|
} |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
return true; |
398
|
|
|
} |
399
|
|
|
|
400
|
|
|
/** |
401
|
|
|
* @private function getCheckReads |
402
|
|
|
* |
403
|
|
|
* @return array|bool |
404
|
|
|
*/ |
405
|
|
|
private function getCheckReads() |
406
|
|
|
{ |
407
|
|
|
foreach (\array_keys($this->tables) as $t) { |
408
|
|
|
if (1 == $this->tables[$t]->getVar('table_reads')) { |
409
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
410
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
411
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
412
|
|
|
$fieldReads = 0; |
413
|
|
|
foreach (\array_keys($fields) as $f) { |
414
|
|
|
if (Constants::FIELD_ELE_TEXTREADS == (int)$fields[$f]->getVar('field_element')) { |
415
|
|
|
$fieldReads++; |
416
|
|
|
} |
417
|
|
|
} |
418
|
|
|
// check whether each table with handling "reads" has also a field "reads" |
419
|
|
|
if (0 == (int)$fieldReads) { |
420
|
|
|
$info = \str_replace('%t', $tableName, \_AM_MODULEBUILDER_BUILDING_CHECK_READS1); |
421
|
|
|
$this->infos[] = ['icon' => 'error', 'info' => $info]; |
422
|
|
|
} |
423
|
|
|
} |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
return true; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* @private function getCheckSql |
431
|
|
|
* |
432
|
|
|
* @return array|bool |
433
|
|
|
*/ |
434
|
|
|
private function getCheckSql() |
435
|
|
|
{ |
436
|
|
|
foreach (\array_keys($this->tables) as $t) { |
437
|
|
|
$tableId = $this->tables[$t]->getVar('table_id'); |
438
|
|
|
$tableName = $this->tables[$t]->getVar('table_name'); |
439
|
|
|
$fields = $this->cf->getTableFields($this->modId, $tableId); |
440
|
|
|
foreach (\array_keys($fields) as $f) { |
441
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
442
|
|
|
$fieldType = $fields[$f]->getVar('field_type'); |
443
|
|
|
if (6 == $fieldType || 7 == $fieldType || 8 == $fieldType) { |
444
|
|
|
$fieldValue = $fields[$f]->getVar('field_value'); |
445
|
|
|
if (0 == \strpos($fieldValue,',')) { |
446
|
|
|
$info = \str_replace(['%f', '%t'], [$fieldName, $tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_SQL1); |
447
|
|
|
$this->infos[] = ['icon' => 'error', 'info' => $info]; |
448
|
|
|
} |
449
|
|
|
$fieldDefault = $fields[$f]->getVar('field_default'); |
450
|
|
|
if (0 == \strpos($fieldDefault,'.')) { |
451
|
|
|
$info = \str_replace(['%f', '%t'], [$fieldName, $tableName], \_AM_MODULEBUILDER_BUILDING_CHECK_SQL2); |
452
|
|
|
$this->infos[] = ['icon' => 'warning', 'info' => $info]; |
453
|
|
|
} |
454
|
|
|
} |
455
|
|
|
} |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
return true; |
459
|
|
|
} |
460
|
|
|
} |
461
|
|
|
|