Passed
Push — master ( 0c230a...202965 )
by Michael
02:53
created

getXoopsVersionNotificationTableName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 8
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * tdmcreate module.
14
 *
15
 * @copyright       XOOPS Project (https://xoops.org)
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 *
18
 * @since           2.5.0
19
 *
20
 * @author          Txmod Xoops http://www.txmodxoops.org
21
 *
22
 * @version         $Id: UserXoopsVersion.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class UserXoopsVersion.
27
 */
28
class UserXoopsVersion extends TDMCreateFile
29
{
30
    /**
31
     * @var array
32
     */
33
    private $kw = [];
34
35
    /**
36
     *  @public function constructor
37
     *  @param null
38
     */
39
    public function __construct()
40
    {
41
        parent::__construct();
42
    }
43
44
    /**
45
     *  @static function getInstance
46
     *  @param null
47
     * @return UserXoopsVersion
48
     */
49
    public static function getInstance()
50
    {
51
        static $instance = false;
52
        if (!$instance) {
53
            $instance = new self();
54
        }
55
56
        return $instance;
57
    }
58
59
    /**
60
     *  @public function write
61
     *  @param $module
62
     *  @param mixed $table
63
     *  @param mixed $tables
64
     *  @param $filename
65
     */
66
    public function write($module, $table, $tables, $filename)
67
    {
68
        $this->setModule($module);
69
        $this->setTable($table);
70
        $this->setTables($tables);
71
        $this->setFileName($filename);
72
        foreach (array_keys($tables) as $t) {
73
            $tableName = $tables[$t]->getVar('table_name');
74
            $this->setKeywords($tableName);
75
        }
76
    }
77
78
    /**
79
     *  @public function setKeywords
80
     *  @param mixed $keywords
81
     */
82
    public function setKeywords($keywords)
83
    {
84
        if (is_array($keywords)) {
85
            $this->kw = $keywords;
86
        } else {
87
            $this->kw[] = $keywords;
88
        }
89
    }
90
91
    /**
92
     *  @public function getKeywords
93
     *  @param null
94
     * @return array
95
     */
96
    public function getKeywords()
97
    {
98
        return $this->kw;
99
    }
100
101
    /**
102
     * @private function getXoopsVersionHeader
103
     * @param $module
104
     * @param $language
105
     *
106
     * @return string
107
     */
108
    private function getXoopsVersionHeader($module, $language)
109
    {
110
        $xCodeVHeader = TDMCreateXoopsCode::getInstance();
111
        $uCodeVHeader = UserXoopsCode::getInstance();
112
        $date = date('Y/m/d');
113
        $ret = $this->getSimpleString('');
114
        $ret .= TDMCreatePhpCode::getInstance()->getPhpCodeCommentLine();
115
        $ret .= $xCodeVHeader->getXcEqualsOperator('$dirname ', 'basename(__DIR__)');
116
        $ret .= $this->getDashComment('Informations');
117
        $ha = (1 == $module->getVar('mod_admin')) ? 1 : 0;
118
        $hm = (1 == $module->getVar('mod_user')) ? 1 : 0;
119
120
        $descriptions = [
121
            'name' => "{$language}NAME", 'version' => "{$module->getVar('mod_version')}", 'description' => "{$language}DESC",
122
            'author' => "'{$module->getVar('mod_author')}'", 'author_mail' => "'{$module->getVar('mod_author_mail')}'", 'author_website_url' => "'{$module->getVar('mod_author_website_url')}'",
123
            'author_website_name' => "'{$module->getVar('mod_author_website_name')}'", 'credits' => "'{$module->getVar('mod_credits')}'", 'license' => "'{$module->getVar('mod_license')}'",
124
            'license_url' => "'http://www.gnu.org/licenses/gpl-3.0.en.html'", 'help' => "'page=help'", 'release_info' => "'{$module->getVar('mod_release_info')}'",
125
            'release_file' => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_release_file')}'", 'release_date' => "'{$date}'",
126
            'manual' => "'{$module->getVar('mod_manual')}'", 'manual_file' => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_manual_file')}'",
127
            'min_php' => "'{$module->getVar('mod_min_php')}'", 'min_xoops' => "'{$module->getVar('mod_min_xoops')}'", 'min_admin' => "'{$module->getVar('mod_min_admin')}'",
128
            'min_db' => "array('mysql' => '{$module->getVar('mod_min_mysql')}', 'mysqli' => '{$module->getVar('mod_min_mysql')}')", 'image' => "'assets/images/{$module->getVar('mod_image')}'",
129
            'dirname' => 'basename(__DIR__)', 'dirmoduleadmin' => "'Frameworks/moduleclasses/moduleadmin'", 'sysicons16' => "'../../Frameworks/moduleclasses/icons/16'",
130
            'sysicons32' => "'../../Frameworks/moduleclasses/icons/32'", 'modicons16' => "'assets/icons/16'", 'modicons32' => "'assets/icons/32'",
131
            'demo_site_url' => "'{$module->getVar('mod_demo_site_url')}'", 'demo_site_name' => "'{$module->getVar('mod_demo_site_name')}'", 'support_url' => "'{$module->getVar('mod_support_url')}'",
132
            'support_name' => "'{$module->getVar('mod_support_name')}'", 'module_website_url' => "'{$module->getVar('mod_website_url')}'", 'module_website_name' => "'{$module->getVar('mod_website_name')}'", 'release' => "'{$module->getVar('mod_release')}'", 'module_status' => "'{$module->getVar('mod_status')}'",
133
            'system_menu' => '1', 'hasAdmin' => $ha, 'hasMain' => $hm, 'adminindex' => "'admin/index.php'", 'adminmenu' => "'admin/menu.php'",
134
            'onInstall' => "'include/install.php'", 'onUpdate' => "'include/update.php'",
135
        ];
136
137
        $ret .= $uCodeVHeader->getUserModVersion(1, $descriptions);
138
139
        return $ret;
140
    }
141
142
    /**
143
     *  @private function getXoopsVersionMySQL
144
     *  @param $moduleDirname
145
     *  @param $table
146
     * @param $tables
147
     * @return string
148
     */
149
    private function getXoopsVersionMySQL($moduleDirname, $table, $tables)
150
    {
151
        $uCodeVMySQL = UserXoopsCode::getInstance();
152
        $tableName = $table->getVar('table_name');
153
        $n = 1;
154
        $ret = '';
155
        if (!empty($tableName)) {
156
            $ret .= $this->getDashComment('Mysql');
157
            $ret .= $uCodeVMySQL->getUserModVersion(2, "'sql/mysql.sql'", 'sqlfile', "'mysql'");
158
            $ret .= TDMCreatePhpCode::getInstance()->getPhpCodeCommentLine('Tables');
159
160
            foreach (array_keys($tables) as $t) {
161
                $ret .= $uCodeVMySQL->getUserModVersion(2, "'{$moduleDirname}_{$tables[$t]->getVar('table_name')}'", 'tables', $n);
162
                ++$n;
163
            }
164
            unset($n);
165
        }
166
167
        return $ret;
168
    }
169
170
    /**
171
     *  @private function getXoopsVersionSearch
172
     * @param $moduleDirname
173
     *
174
     * @return string
175
     */
176
    private function getXoopsVersionSearch($moduleDirname)
177
    {
178
        $uCodeVSearch = UserXoopsCode::getInstance();
179
        $ret = $this->getDashComment('Search');
180
        $ret .= $uCodeVSearch->getUserModVersion(1, 1, 'hasSearch');
181
        $ret .= $uCodeVSearch->getUserModVersion(2, "'include/search.inc.php'", 'search', "'file'");
182
        $ret .= $uCodeVSearch->getUserModVersion(2, "'{$moduleDirname}_search'", 'search', "'func'");
183
184
        return $ret;
185
    }
186
187
    /**
188
     *  @private function getXoopsVersionComments
189
     *  @param $moduleDirname
190
     *
191
     * @return string
192
     */
193
    private function getXoopsVersionComments($moduleDirname)
194
    {
195
        $uCodeVComments = UserXoopsCode::getInstance();
196
        $ret = $this->getDashComment('Comments');
197
        $ret .= $uCodeVComments->getUserModVersion(2, "'comments.php'", 'comments', "'pageName'");
198
        $ret .= $uCodeVComments->getUserModVersion(2, "'com_id'", 'comments', "'itemName'");
199
        $ret .= TDMCreatePhpCode::getInstance()->getPhpCodeCommentLine('Comment callback functions');
200
        $ret .= $uCodeVComments->getUserModVersion(2, "'include/comment_functions.php'", 'comments', "'callbackFile'");
201
        $descriptions = ['approve' => "'{$moduleDirname}CommentsApprove'", 'update' => "'{$moduleDirname}CommentsUpdate'"];
202
        $ret .= $uCodeVComments->getUserModVersion(3, $descriptions, 'comments', "'callback'");
203
204
        return $ret;
205
    }
206
207
    /**
208
     *  @private function getXoopsVersionTemplatesAdmin
209
     *  @param $moduleDirname
210
     * @param $tables
211
     *
212
     * @return string
213
     */
214
    private function getXoopsVersionTemplatesAdmin($moduleDirname, $tables)
215
    {
216
        $ret = $this->getDashComment('Templates');
217
        $ret .= TDMCreatePhpCode::getInstance()->getPhpCodeCommentLine('Admin');
218
219
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'about', '', true);
220
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', '', true);
221
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', '', true);
222
        $tablePermissions = [];
223
        foreach (array_keys($tables) as $t) {
224
            $tableName = $tables[$t]->getVar('table_name');
225
            $tablePermissions[] = $tables[$t]->getVar('table_permissions');
226
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, '', true);
227
        }
228
        if (in_array(1, $tablePermissions, true)) {
229
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'permissions', '', true);
230
        }
231
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', '', true);
232
233
        return $ret;
234
    }
235
236
    /**
237
     *  @private function getXoopsVersionTemplatesLine
238
     * @param        $moduleDirname
239
     * @param        $type
240
     * @param string $extra
241
     * @param bool   $isAdmin
242
     * @return string
243
     */
244
    private function getXoopsVersionTemplatesLine($moduleDirname, $type, $extra = '', $isAdmin = false)
245
    {
246
        $uCodeVTLine = UserXoopsCode::getInstance();
247
        $ret = '';
248
        $desc = "'description' => ''";
249
        $arrayFile = "array('file' =>";
250
        if ($isAdmin) {
251
            $ret .= $uCodeVTLine->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_admin_{$type}.tpl', {$desc}, 'type' => 'admin')", 'templates', '');
252
        } else {
253
            if ('' !== $extra) {
254
                $ret .= $uCodeVTLine->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_{$type}_{$extra}.tpl', {$desc})", 'templates', '');
255
            } else {
256
                $ret .= $uCodeVTLine->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_{$type}.tpl', {$desc})", 'templates', '');
257
            }
258
        }
259
260
        return $ret;
261
    }
262
263
    /**
264
     *  @private function getXoopsVersionTemplatesUser
265
     *  @param $moduleDirname
266
     * @param $tables
267
     * @return string
268
     */
269
    private function getXoopsVersionTemplatesUser($moduleDirname, $tables)
270
    {
271
        $ret = TDMCreatePhpCode::getInstance()->getPhpCodeCommentLine('User');
272
273
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', '');
274
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', '');
275
        $tableBroken = [];
276
        $tablePdf = [];
277
        $tablePrint = [];
278
        $tableRate = [];
279
        $tableRss = [];
280
        $tableSearch = [];
281
        $tableSingle = [];
282
        $tableSubmit = [];
283
        foreach (array_keys($tables) as $t) {
284
            $tableName = $tables[$t]->getVar('table_name');
285
            $tableBroken[] = $tables[$t]->getVar('table_broken');
286
            $tablePdf[] = $tables[$t]->getVar('table_pdf');
287
            $tablePrint[] = $tables[$t]->getVar('table_print');
288
            $tableRate[] = $tables[$t]->getVar('table_rate');
289
            $tableRss[] = $tables[$t]->getVar('table_rss');
290
            $tableSearch[] = $tables[$t]->getVar('table_search');
291
            $tableSingle[] = $tables[$t]->getVar('table_single');
292
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
293
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, '');
294
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, 'list');
295
        }
296
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'breadcrumbs', '');
297
        if (in_array(1, $tableBroken, true)) {
298
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'broken', '');
299
        }
300
        if (in_array(1, $tablePdf, true)) {
301
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'pdf', '');
302
        }
303
        if (in_array(1, $tablePrint, true)) {
304
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'print', '');
305
        }
306
        if (in_array(1, $tableRate, true)) {
307
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'rate', '');
308
        }
309
        if (in_array(1, $tableRss, true)) {
310
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'rss', '');
311
        }
312
        if (in_array(1, $tableSearch, true)) {
313
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'search', '');
314
        }
315
        if (in_array(1, $tableSingle, true)) {
316
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'single', '');
317
        }
318
        if (in_array(1, $tableSubmit, true)) {
319
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'submit', '');
320
        }
321
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', '');
322
323
        return $ret;
324
    }
325
326
    /**
327
     *  @private function getXoopsVersionSubmenu
328
     * @param $language
329
     * @param $tables
330
     * @return string
331
     */
332
    private function getXoopsVersionSubmenu($language, $tables)
333
    {
334
        $phpCodeVSubmenu = TDMCreatePhpCode::getInstance();
335
        $uCodeVSubmenu = UserXoopsCode::getInstance();
336
        $ret = $this->getDashComment('Submenu');
337
        $i = 1;
338
        $tableSubmit = [];
339
        foreach (array_keys($tables) as $t) {
340
            $tableName = $tables[$t]->getVar('table_name');
341
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
342
            if (1 == $tables[$t]->getVar('table_submenu')) {
343
                $ret .= $phpCodeVSubmenu->getPhpCodeCommentLine('Sub', $tableName);
344
                $tname = ['name' => "{$language}SMNAME{$i}", 'url' => "'{$tableName}.php'"];
345
                $ret .= $uCodeVSubmenu->getUserModVersion(3, $tname, 'sub', $i);
346
            }
347
            ++$i;
348
        }
349
        if (in_array(1, $tableSubmit, true)) {
350
            $ret .= $phpCodeVSubmenu->getPhpCodeCommentLine('Sub', 'Submit');
351
            $submit = ['name' => "{$language}SMNAME{$i}", 'url' => "'submit.php'"];
352
            $ret .= $uCodeVSubmenu->getUserModVersion(3, $submit, 'sub', $i);
353
        }
354
        unset($i);
355
356
        return $ret;
357
    }
358
359
    /**
360
     *  @private function getXoopsVersionBlocks
361
     * @param $moduleDirname
362
     * @param $tables
363
     * @param $language
364
     * @return string
365
     */
366
    private function getXoopsVersionBlocks($moduleDirname, $tables, $language)
367
    {
368
        $ret = $this->getDashComment('Blocks');
369
        $ret .= $this->getSimpleString('$b = 1;');
370
        $tableCategory = [];
371
        foreach (array_keys($tables) as $i) {
372
            $tableName = $tables[$i]->getVar('table_name');
373
            $tableFieldName = $tables[$i]->getVar('table_fieldname');
374
            $tableSoleName = $tables[$i]->getVar('table_solename');
375
            $stuTableSoleName = mb_strtoupper($tableSoleName);
376
            $tableCategory[] = $tables[$i]->getVar('table_category');
377
            if (in_array(1, $tableCategory, true)) {
378
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $tableFieldName);
379
            } else {
380
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'LAST', $language, 'last');
381
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'NEW', $language, 'new');
382
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'HITS', $language, 'hits');
383
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'TOP', $language, 'top');
384
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'RANDOM', $language, 'random');
385
            }
386
        }
387
        $ret .= $this->getSimpleString('unset($b);');
388
389
        return $ret;
390
    }
391
392
    /**
393
     *  @private function getXoopsVersionTypeBlocks
394
     * @param $moduleDirname
395
     * @param $tableName
396
     * @param $stuTableSoleName
397
     * @param $language
398
     * @param $type
399
     * @return string
400
     */
401
    private function getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $type)
402
    {
403
        $phpCodeVTBlocks = TDMCreatePhpCode::getInstance();
404
        $uCodeVTBlocks = UserXoopsCode::getInstance();
405
        $stuTableName = mb_strtoupper($tableName);
406
        $ucfTableName = ucfirst($tableName);
407
        $ret = $phpCodeVTBlocks->getPhpCodeCommentLine("{$ucfTableName}");
408
        $blocks = [
409
            'file' => "'{$tableName}.php'", 'name' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}", 'description' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}_DESC",
410
            'show_func' => "'b_{$moduleDirname}_{$tableName}_show'", 'edit_func' => "'b_{$moduleDirname}_{$tableName}_edit'",
411
            'template' => "'{$moduleDirname}_block_{$tableName}.tpl'", 'options' => "'{$type}|5|25|0'",
412
        ];
413
        $ret .= $uCodeVTBlocks->getUserModVersion(3, $blocks, 'blocks', '$b');
414
        $ret .= $this->getSimpleString('++$b;');
415
416
        return $ret;
417
    }
418
419
    /**
420
     * @private function getXoopsVersionConfig
421
     * @param $module
422
     * @param $tables
423
     * @param $language
424
     *
425
     * @return string
426
     */
427
    private function getXoopsVersionConfig($module, $tables, $language)
428
    {
429
        $phpCodeVConfig = TDMCreatePhpCode::getInstance();
430
        $xCodeVConfig = TDMCreateXoopsCode::getInstance();
431
        $uCodeVConfig = UserXoopsCode::getInstance();
432
        $moduleDirname = $module->getVar('mod_dirname');
433
        $ret = $this->getDashComment('Config');
434
        $ret .= $this->getSimpleString('$c = 1;');
435
436
        $table_permissions = 0;
437
        $table_admin = 0;
438
        $table_user = 0;
439
        $table_tag = 0;
440
        $field_images = 0;
441
        foreach ($tables as $table) {
442
            $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
443
            foreach (array_keys($fields) as $f) {
444
                $fieldElement = $fields[$f]->getVar('field_element');
445
                switch ($fieldElement) {
446
                    case '3':
447
                    case '4':
448
                    case 3:
449
                    case 4:
450
                        $fieldName = $fields[$f]->getVar('field_name');
451
                        $rpFieldName = $this->getRightString($fieldName);
452
                        $ucfFieldName = ucfirst($rpFieldName);
453
                        $stuFieldName = mb_strtoupper($rpFieldName);
454
                        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Editor', $rpFieldName);
455
                        $ret .= $xCodeVConfig->getXcLoad('xoopseditorhandler');
456
                        $ret .= $xCodeVConfig->getXcEqualsOperator('$editorHandler' . $ucfFieldName, 'XoopsEditorHandler::getInstance()');
457
                        $editor = [
458
                            'name' => "'editor_{$rpFieldName}'", 'title' => "'{$language}EDITOR_{$stuFieldName}'", 'description' => "'{$language}EDITOR_{$stuFieldName}_DESC'",
459
                            'formtype' => "'select'", 'valuetype' => "'text'", 'default' => "'dhtml'", 'options' => 'array_flip($editorHandler' . $ucfFieldName . '->getList())',
460
                        ];
461
                        $ret .= $uCodeVConfig->getUserModVersion(3, $editor, 'config', '$c');
462
                        $ret .= $this->getSimpleString('++$c;');
463
                    break;
464
                    case '10':
465
                    case '11':
466
                    case '12':
467
                    case '13':
468
                    case '14':
469
                    case 10:
470
                    case 11:
471
                    case 12:
472
                    case 13:
473
                    case 14:
474
                        $field_images = 1;
475
                    break;
476
                    case 'else':
477
                    default:
478
                    break;
479
                }
480
            }
481
            if (1 == $table->getVar('table_permissions')) {
482
                $table_permissions = 1;
483
            }
484
            if (1 == $table->getVar('table_admin')) {
485
                $table_admin = 1;
486
            }
487
            if (1 == $table->getVar('table_user')) {
488
                $table_user = 1;
489
            }
490
            if (1 == $table->getVar('table_tag')) {
491
                $table_tag = 1;
492
            }
493
        }
494
495
        if (1 === $table_permissions) {
496
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Get groups');
497
            $ret .= $xCodeVConfig->getXcEqualsOperator('$memberHandler ', "xoops_getHandler('member')", '', false);
498
            $ret .= $xCodeVConfig->getXcEqualsOperator('$xoopsGroups ', '$memberHandler->getGroupList()');
499
            $group = $xCodeVConfig->getXcEqualsOperator('$groups[$group] ', '$key', null, false, "\t");
500
            $ret .= $phpCodeVConfig->getPhpCodeForeach('xoopsGroups', false, 'key', 'group', $group);
501
            $groups = [
502
                'name' => "'groups'", 'title' => "'{$language}GROUPS'", 'description' => "'{$language}GROUPS_DESC'",
503
                'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => '$groups', 'options' => '$groups',
504
            ];
505
            $ret .= $uCodeVConfig->getUserModVersion(3, $groups, 'config', '$c');
506
            $ret .= $this->getSimpleString('++$c;');
507
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Get Admin groups');
508
            $ret .= $xCodeVConfig->getXcEqualsOperator('$criteria ', 'new CriteriaCompo()');
509
            $ret .= $this->getSimpleString("\$criteria->add( new Criteria( 'group_type', 'Admin' ) );");
510
            $ret .= $xCodeVConfig->getXcEqualsOperator('$memberHandler ', "xoops_getHandler('member')", '', false);
511
            $ret .= $xCodeVConfig->getXcEqualsOperator('$adminXoopsGroups ', '$memberHandler->getGroupList($criteria)');
512
            $adminGroup = $xCodeVConfig->getXcEqualsOperator('$adminGroups[$adminGroup] ', '$key', null, false, "\t");
513
            $ret .= $phpCodeVConfig->getPhpCodeForeach('adminXoopsGroups', false, 'key', 'adminGroup', $adminGroup);
514
            $adminGroups = [
515
                'name' => "'admin_groups'", 'title' => "'{$language}GROUPS'", 'description' => "'{$language}GROUPS_DESC'",
516
                'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => '$adminGroups', 'options' => '$adminGroups',
517
            ];
518
            $ret .= $uCodeVConfig->getUserModVersion(3, $adminGroups, 'config', '$c');
519
            $ret .= $this->getSimpleString('++$c;');
520
        }
521
        $keyword = implode(', ', $this->getKeywords());
522
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Keywords');
523
        $arrayKeyword = [
524
            'name' => "'keywords'", 'title' => "'{$language}KEYWORDS'", 'description' => "'{$language}KEYWORDS_DESC'",
525
            'formtype' => "'textbox'", 'valuetype' => "'text'", 'default' => "'{$moduleDirname}, {$keyword}'",
526
        ];
527
        $ret .= $uCodeVConfig->getUserModVersion(3, $arrayKeyword, 'config', '$c');
528
        $ret .= $this->getSimpleString('++$c;');
529
        unset($this->keywords);
530
531
        if (1 === $field_images) {
532
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Uploads : maxsize of image');
533
            $maxsize = [
534
                'name' => "'maxsize'", 'title' => "'{$language}MAXSIZE'", 'description' => "'{$language}MAXSIZE_DESC'",
535
                'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '5000000',
536
            ];
537
            $ret .= $uCodeVConfig->getUserModVersion(3, $maxsize, 'config', '$c');
538
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Uploads : mimetypes of image');
539
            $ret .= $this->getSimpleString('++$c;');
540
            $mimetypes = [
541
                'name' => "'mimetypes'", 'title' => "'{$language}MIMETYPES'", 'description' => "'{$language}MIMETYPES_DESC'",
542
                'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => "array('image/gif', 'image/jpeg', 'image/png')",
543
                'options' => "array('bmp' => 'image/bmp','gif' => 'image/gif','pjpeg' => 'image/pjpeg', 'jpeg' => 'image/jpeg','jpg' => 'image/jpg','jpe' => 'image/jpe', 'png' => 'image/png')",
544
            ];
545
            $ret .= $uCodeVConfig->getUserModVersion(3, $mimetypes, 'config', '$c');
546
            $ret .= $this->getSimpleString('++$c;');
547
        }
548
        if (1 === $table_admin) {
549
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Admin pager');
550
            $adminPager = [
551
                'name' => "'adminpager'", 'title' => "'{$language}ADMIN_PAGER'", 'description' => "'{$language}ADMIN_PAGER_DESC'",
552
                'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '10',
553
            ];
554
            $ret .= $uCodeVConfig->getUserModVersion(3, $adminPager, 'config', '$c');
555
            $ret .= $this->getSimpleString('++$c;');
556
        }
557
        if (1 === $table_user) {
558
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('User pager');
559
            $userPager = [
560
                'name' => "'userpager'", 'title' => "'{$language}USER_PAGER'", 'description' => "'{$language}USER_PAGER_DESC'",
561
                'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '10',
562
            ];
563
            $ret .= $uCodeVConfig->getUserModVersion(3, $userPager, 'config', '$c');
564
            $ret .= $this->getSimpleString('++$c;');
565
        }
566
        if (1 === $table_tag) {
567
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Use tag');
568
            $useTag = [
569
                'name' => "'usetag'", 'title' => "'{$language}USE_TAG'", 'description' => "'{$language}USE_TAG_DESC'",
570
                'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0',
571
            ];
572
            $ret .= $uCodeVConfig->getUserModVersion(3, $useTag, 'config', '$c');
573
            $ret .= $this->getSimpleString('++$c;');
574
        }
575
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Number column');
576
        $numbCol = [
577
            'name' => "'numb_col'", 'title' => "'{$language}NUMB_COL'", 'description' => "'{$language}NUMB_COL_DESC'",
578
            'formtype' => "'select'", 'valuetype' => "'int'", 'default' => '1', 'options' => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')",
579
        ];
580
        $ret .= $uCodeVConfig->getUserModVersion(3, $numbCol, 'config', '$c');
581
        $ret .= $this->getSimpleString('++$c;');
582
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Divide by');
583
        $divideby = [
584
            'name' => "'divideby'", 'title' => "'{$language}DIVIDEBY'", 'description' => "'{$language}DIVIDEBY_DESC'",
585
            'formtype' => "'select'", 'valuetype' => "'int'", 'default' => '1', 'options' => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')",
586
        ];
587
        $ret .= $uCodeVConfig->getUserModVersion(3, $divideby, 'config', '$c');
588
        $ret .= $this->getSimpleString('++$c;');
589
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Table type');
590
        $tableType = [
591
            'name' => "'table_type'", 'title' => "'{$language}TABLE_TYPE'", 'description' => "'{$language}DIVIDEBY_DESC'",
592
            'formtype' => "'select'", 'valuetype' => "'int'", 'default' => "'bordered'", 'options' => "array('bordered' => 'bordered', 'striped' => 'striped', 'hover' => 'hover', 'condensed' => 'condensed')",
593
        ];
594
        $ret .= $uCodeVConfig->getUserModVersion(3, $tableType, 'config', '$c');
595
        $ret .= $this->getSimpleString('++$c;');
596
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Panel by');
597
        $panelType = [
598
            'name' => "'panel_type'", 'title' => "'{$language}PANEL_TYPE'", 'description' => "'{$language}PANEL_TYPE_DESC'",
599
            'formtype' => "'select'", 'valuetype' => "'text'", 'default' => "'default'", 'options' => "array('default' => 'default', 'primary' => 'primary', 'success' => 'success', 'info' => 'info', 'warning' => 'warning', 'danger' => 'danger')",
600
        ];
601
        $ret .= $uCodeVConfig->getUserModVersion(3, $panelType, 'config', '$c');
602
        $ret .= $this->getSimpleString('++$c;');
603
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Advertise');
604
        $advertise = [
605
            'name' => "'advertise'", 'title' => "'{$language}ADVERTISE'", 'description' => "'{$language}ADVERTISE_DESC'",
606
            'formtype' => "'textarea'", 'valuetype' => "'text'", 'default' => "''",
607
        ];
608
        $ret .= $uCodeVConfig->getUserModVersion(3, $advertise, 'config', '$c');
609
        $ret .= $this->getSimpleString('++$c;');
610
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Bookmarks');
611
        $bookmarks = [
612
            'name' => "'bookmarks'", 'title' => "'{$language}BOOKMARKS'", 'description' => "'{$language}BOOKMARKS_DESC'",
613
            'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0',
614
        ];
615
        $ret .= $uCodeVConfig->getUserModVersion(3, $bookmarks, 'config', '$c');
616
        $ret .= $this->getSimpleString('++$c;');
617
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Facebook Comments');
618
        $facebookComments = [
619
            'name' => "'facebook_comments'", 'title' => "'{$language}FACEBOOK_COMMENTS'", 'description' => "'{$language}FACEBOOK_COMMENTS_DESC'",
620
            'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0',
621
        ];
622
        $ret .= $uCodeVConfig->getUserModVersion(3, $facebookComments, 'config', '$c');
623
        $ret .= $this->getSimpleString('++$c;');
624
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Disqus Comments');
625
        $disqusComments = [
626
            'name' => "'disqus_comments'", 'title' => "'{$language}DISQUS_COMMENTS'", 'description' => "'{$language}DISQUS_COMMENTS_DESC'",
627
            'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0',
628
        ];
629
        $ret .= $uCodeVConfig->getUserModVersion(3, $disqusComments, 'config', '$c');
630
        $ret .= $this->getSimpleString('++$c;');
631
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Maintained by');
632
        $maintainedby = [
633
            'name' => "'maintainedby'", 'title' => "'{$language}MAINTAINEDBY'", 'description' => "'{$language}MAINTAINEDBY_DESC'",
634
            'formtype' => "'textbox'", 'valuetype' => "'text'", 'default' => "'{$module->getVar('mod_support_url')}'",
635
        ];
636
        $ret .= $uCodeVConfig->getUserModVersion(3, $maintainedby, 'config', '$c');
637
        $ret .= $this->getSimpleString('unset($c);');
638
639
        return $ret;
640
    }
641
642
    /**
643
     *  @private function getNotificationsType
644
     * @param $language
645
     * @param $type
646
     * @param $tableName
647
     * @param $notifyFile
648
     * @param $item
649
     * @param $typeOfNotify
650
     *
651
     * @return string
652
     */
653
    private function getNotificationsType($language, $type, $tableName, $notifyFile, $item, $typeOfNotify)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
654
    {
655
        $phpCodeNType = TDMCreatePhpCode::getInstance();
656
        $uCodeNType = UserXoopsCode::getInstance();
657
        $stuTableName = mb_strtoupper($tableName);
658
        $stuTypeOfNotify = mb_strtoupper($typeOfNotify);
659
        $notifyFile = explode(', ', $notifyFile);
660
        $notifyFile = implode(', ', $notifyFile);
661
        $ret = '';
662
        switch ($type) {
663
            case 'category':
664
                $ret .= $phpCodeNType->getPhpCodeCommentLine('Category Notify');
665
                $category = [
666
                    'name' => "'category'", 'title' => "'{$language}{$stuTableName}_NOTIFY'", 'description' => "'{$language}{$stuTableName}_NOTIFY_DESC'",
667
                    'subscribe_from' => "array('index.php',{$notifyFile})", 'item_name' => "'{$item}'", "'allow_bookmark'" => '1',
668
                ];
669
                $ret .= $uCodeNType->getUserModVersion(3, $category, 'notification', "'{$type}'");
670
                break;
671
            case 'event':
672
                $ret .= $phpCodeNType->getPhpCodeCommentLine('Event Notify');
673
                $event = [
674
                    'name' => "'{$typeOfNotify}'", 'category' => "'{$tableName}'", 'admin_only' => '1', "'title'" => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY'",
675
                    'caption' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_CAPTION'", 'description' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_DESC'",
676
                    'mail_template' => "'{$tableName}_{$typeOfNotify}_notify'", 'mail_subject' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_SUBJECT'",
677
                ];
678
                $ret .= $uCodeNType->getUserModVersion(3, $event, 'notification', "'{$type}'");
679
                break;
680
        }
681
682
        return $ret;
683
    }
684
685
    /**
686
     *  @private function getXoopsVersionNotifications
687
     * @param $module
688
     * @param $language
689
     * @return string
690
     */
691
    private function getXoopsVersionNotifications($module, $language)
692
    {
693
        $uCodeVN = UserXoopsCode::getInstance();
694
        $moduleDirname = $module->getVar('mod_dirname');
695
        $ret = $this->getDashComment('Notifications');
696
        $ret .= $uCodeVN->getUserModVersion(1, 1, 'hasNotification');
697
        $notifications = ["'lookup_file'" => "'include/notification.inc.php'", "'lookup_func'" => "'{$moduleDirname}_notify_iteminfo'"];
698
        $ret .= $uCodeVN->getUserModVersion(2, $notifications, 'notification');
699
700
        $notifyFiles = [];
701
        $single = 'single';
702
        $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order');
703
        $tableCategory = [];
704
        $tableBroken = [];
705
        $tableSubmit = [];
706
        $tableId = null;
707
        $tableMid = null;
708
        foreach (array_keys($tables) as $t) {
709
            $tableId = $tables[$t]->getVar('table_id');
710
            $tableMid = $tables[$t]->getVar('table_mid');
711
            $tableName = $tables[$t]->getVar('table_name');
712
            $tableSoleName = $tables[$t]->getVar('table_solename');
713
            $tableCategory[] = $tables[$t]->getVar('table_category');
714
            $tableBroken[] = $tables[$t]->getVar('table_broken');
715
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
716
            if (1 == $tables[$t]->getVar('table_notifications')) {
717
                if ($t <= count($tableName)) {
718
                    $notifyFiles[] = $tables[$t]->getVar('table_name');
719
                }
720
            }
721
            if (1 == $tables[$t]->getVar('table_single')) {
722
                $single = $tableName;
723
            }
724
        }
725
        $fields = $this->getTableFields($tableMid, $tableId);
726
        $fieldId = null;
727
        $fieldParent = null;
728
        foreach (array_keys($fields) as $f) {
729
            $fieldName = $fields[$f]->getVar('field_name');
730
            $fieldElement = $fields[$f]->getVar('field_element');
731
            if (0 == $f) {
732
                $fieldId = $fieldName;
733
            }
734
            if ($fieldElement > 15) {
735
                $fieldParent = $fieldName;
736
            }
737
        }
738
739
        $num = 1;
740
        $ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', 'global', $notifyFiles, $num);
741
        ++$num;
742
        $ret .= $this->getXoopsVersionNotificationCategory($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1', $num);
743
        ++$num;
744
        $ret .= $this->getXoopsVersionNotificationTableName($language, 'category', $tableSoleName, $tableSoleName, $single, $fieldId, 1, $num);
0 ignored issues
show
Bug introduced by
The variable $tableSoleName does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
745
        unset($num);
746
        $num = 1;
747
        if (in_array(1, $tableCategory, true)) {
748
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'global', 0, 'global', 'newcategory', 'global_newcategory_notify', $num);
749
            ++$num;
750
        }
751
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_modify', 'global', 1, 'global', $tableSoleName . 'modify', 'global_' . $tableSoleName . 'modify_notify', $num);
752
        if (in_array(1, $tableBroken, true)) {
753
            ++$num;
754
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_broken', 'global', 1, 'global', $tableSoleName . 'broken', 'global_' . $tableSoleName . 'broken_notify', $num);
755
        }
756
        if (in_array(1, $tableSubmit, true)) {
757
            ++$num;
758
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_submit', 'global', 1, 'global', $tableSoleName . 'submit', 'global_' . $tableSoleName . 'submit_notify', $num);
759
        }
760
        ++$num;
761
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_' . $tableSoleName, 'global', 0, 'global', 'new' . $tableSoleName, 'global_new' . $tableSoleName . '_notify', $num);
762
        if (in_array(1, $tableCategory, true)) {
763
            ++$num;
764
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_submit', 'category', 1, 'category', $tableSoleName . 'submit', 'category_' . $tableSoleName . 'submit_notify', $num);
765
            ++$num;
766
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_' . $tableSoleName, 'category', 0, 'category', 'new' . $tableSoleName, 'category_new' . $tableSoleName . '_notify', $num);
767
        }
768
        ++$num;
769
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'approve', $tableSoleName, 1, $tableSoleName, 'approve', $tableSoleName . '_approve_notify', $num);
770
        unset($num);
771
772
        return $ret;
773
    }
774
775
    /**
776
     *  @private function getXoopsVersionNotificationGlobal
777
     * @param $language
778
     * @param $type
779
     * @param $name
780
     * @param $title
781
     * @param $from
782
     *
783
     * @param $num
784
     * @return string
785
     */
786
    private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from, $num)
787
    {
788
        $phpCodeVNG = TDMCreatePhpCode::getInstance();
789
        $uCodeVNG = UserXoopsCode::getInstance();
790
        $title = mb_strtoupper($title);
791
        $implodeFrom = implode(".php', '", $from);
792
        $ret = $phpCodeVNG->getPhpCodeCommentLine('Global Notify');
793
        $global = [
794
            'name' => "'{$name}'", 'title' => "{$language}{$title}_NOTIFY", 'description' => "{$language}{$title}_NOTIFY_DESC",
795
            'subscribe_from' => "array('index.php', '{$implodeFrom}.php')",
796
        ];
797
        $ret .= $uCodeVNG->getUserModVersion(4, $global, 'notification', "'{$type}'", $num);
798
799
        return $ret;
800
    }
801
802
    /**
803
     *  @private function getXoopsVersionNotificationCategory
804
     * @param $language
805
     * @param $type
806
     * @param $name
807
     * @param $title
808
     * @param $file
809
     * @param $item
810
     * @param $allow
811
     * @param $num
812
     * @return string
813
     */
814
    private function getXoopsVersionNotificationCategory($language, $type, $name, $title, $file, $item, $allow, $num)
815
    {
816
        $phpCodeVNC = TDMCreatePhpCode::getInstance();
817
        $uCodeVNC = UserXoopsCode::getInstance();
818
        $title = mb_strtoupper($title);
819
        $impFile = implode(".php', '", $file);
820
        $ret = $phpCodeVNC->getPhpCodeCommentLine('Category Notify');
821
        $global = [
822
            'name' => "'{$name}'", 'title' => "{$language}{$title}_NOTIFY", 'description' => "{$language}{$title}_NOTIFY_DESC",
823
            'subscribe_from' => "array('{$impFile}.php')", 'item_name' => "'{$item}'", 'allow_bookmark' => "{$allow}",
824
        ];
825
        $ret .= $uCodeVNC->getUserModVersion(4, $global, 'notification', "'{$type}'", $num);
826
827
        return $ret;
828
    }
829
830
    /**
831
     *  @private function getXoopsVersionNotificationTableName
832
     * @param $language
833
     * @param $type
834
     * @param $name
835
     * @param $title
836
     * @param $file
837
     * @param $item
838
     * @param $allow
839
     *
840
     * @param $num
841
     * @return string
842
     */
843
    private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $file, $item, $allow, $num)
844
    {
845
        $phpCodeVNTN = TDMCreatePhpCode::getInstance();
846
        $uCodeVNTN = UserXoopsCode::getInstance();
847
        $stuTitle = mb_strtoupper($title);
848
        $ucfTitle = ucfirst($title);
849
        $ret = $phpCodeVNTN->getPhpCodeCommentLine($ucfTitle . ' Notify');
850
        $table = [
851
            'name' => "'{$name}'", 'title' => "{$language}{$stuTitle}_NOTIFY", 'description' => "{$language}{$stuTitle}_NOTIFY_DESC",
852
            'subscribe_from' => "'{$file}.php'", 'item_name' => "'{$item}'", 'allow_bookmark' => "{$allow}",
853
        ];
854
        $ret .= $uCodeVNTN->getUserModVersion(4, $table, 'notification', "'{$type}'", $num);
855
856
        return $ret;
857
    }
858
859
    /**
860
     *  @private function getXoopsVersionNotifications
861
     * @param $language
862
     * @param $type
863
     * @param $name
864
     * @param $category
865
     * @param $admin
866
     * @param $title
867
     * @param $table
868
     * @param $mail
869
     *
870
     * @param $num
871
     * @return string
872
     */
873
    private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin, $title, $table, $mail, $num)
874
    {
875
        $phpCodeVNCC = TDMCreatePhpCode::getInstance();
876
        $uCodeVNCC = UserXoopsCode::getInstance();
877
        $title = mb_strtoupper($title);
878
        $table = mb_strtoupper($table);
879
        $ucfTitle = ucfirst($title);
880
        $ret = $phpCodeVNCC->getPhpCodeCommentLine($ucfTitle . ' Notify');
881
        $event = [
882
            'name' => "'{$name}'", 'category' => "'{$category}'", 'admin_only' => "{$admin}", 'title' => "{$language}{$title}_{$table}_NOTIFY",
883
            'caption' => "{$language}{$title}_{$table}_NOTIFY_CAPTION", 'description' => "{$language}{$title}_{$table}_NOTIFY_DESC",
884
            'mail_template' => "'{$mail}'", 'mail_subject' => "{$language}{$title}_{$table}_NOTIFY_SUBJECT",
885
        ];
886
        $ret .= $uCodeVNCC->getUserModVersion(4, $event, 'notification', "'{$type}'", $num);
887
888
        return $ret;
889
    }
890
891
    /**
892
     *  @public function render
893
     *  @param null
894
     * @return bool|string
895
     */
896
    public function render()
897
    {
898
        $module = $this->getModule();
899
        $table = $this->getTable();
900
        $tables = $this->getTables();
901
        $filename = $this->getFileName();
902
        $moduleDirname = $module->getVar('mod_dirname');
903
        $language = $this->getLanguage($moduleDirname, 'MI');
904
        $content = $this->getHeaderFilesComments($module, $filename);
905
        $content .= $this->getXoopsVersionHeader($module, $language);
906
        if (1 == $module->getVar('mod_admin')) {
907
            $content .= $this->getXoopsVersionTemplatesAdmin($moduleDirname, $tables);
908
        }
909
        if (1 == $module->getVar('mod_user')) {
910
            $content .= $this->getXoopsVersionTemplatesUser($moduleDirname, $tables);
911
        }
912
        $content .= $this->getXoopsVersionMySQL($moduleDirname, $table, $tables);
913
        $tableSearch = [];
914
        $tableComments = [];
915
        $tableSubmenu = [];
916
        $tableBlocks = [];
917
        $tableNotifications = [];
918
        foreach (array_keys($tables) as $t) {
919
            $tableSearch[] = $tables[$t]->getVar('table_search');
920
            $tableComments[] = $tables[$t]->getVar('table_comments');
921
            $tableSubmenu[] = $tables[$t]->getVar('table_submenu');
922
            $tableBlocks[] = $tables[$t]->getVar('table_blocks');
923
            $tableNotifications[] = $tables[$t]->getVar('table_notifications');
924
        }
925
        if (in_array(1, $tableSearch, true)) {
926
            $content .= $this->getXoopsVersionSearch($moduleDirname);
927
        }
928
        if (in_array(1, $tableComments, true)) {
929
            $content .= $this->getXoopsVersionComments($moduleDirname);
930
        }
931
        if (in_array(1, $tableSubmenu, true)) {
932
            $content .= $this->getXoopsVersionSubmenu($language, $tables);
933
        }
934
        if (in_array(1, $tableBlocks, true)) {
935
            $content .= $this->getXoopsVersionBlocks($moduleDirname, $tables, $language);
936
        }
937
        $content .= $this->getXoopsVersionConfig($module, $tables, $language);
938
        if (in_array(1, $tableNotifications, true)) {
939
            $content .= $this->getXoopsVersionNotifications($module, $language);
940
        }
941
        $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
942
943
        return $this->renderFile();
944
    }
945
}
946