Code Duplication    Length = 15-15 lines in 2 locations

install/cli-install.php 1 location

@@ 1311-1325 (lines=15) @@
1308
                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1309
                }
1310
                // add system events
1311
                if (count($events) > 0) {
1312
                    $ds = mysqli_query($sqlParser->conn,
1313
                        "SELECT id FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name' AND description='$desc';");
1314
                    if ($ds) {
1315
                        $row = mysqli_fetch_assoc($ds);
1316
                        $id = $row["id"];
1317
                        $_events = implode("','", $events);
1318
                        // add new events
1319
                        $sql = "INSERT IGNORE INTO $dbase.`" . $table_prefix . "site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`" . $table_prefix . "system_eventnames` se WHERE name IN ('{$_events}')";
1320
                        mysqli_query($sqlParser->conn, $sql);
1321
                        // remove absent events
1322
                        $sql = "DELETE `pe` FROM {$dbase}.`{$table_prefix}site_plugin_events` `pe` LEFT JOIN {$dbase}.`{$table_prefix}system_eventnames` `se` ON `pe`.`evtid`=`se`.`id` AND `name` IN ('{$_events}') WHERE ISNULL(`name`) AND `pluginid` = {$id}";
1323
                        mysqli_query($sqlParser->conn, $sql);
1324
                    }
1325
                }
1326
            }
1327
        }
1328
    }

install/src/controllers/install.php 1 location

@@ 727-741 (lines=15) @@
724
                        }
725
                    }
726
                    // add system events
727
                    if (count($events) > 0) {
728
                        $query = "SELECT id FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name' AND description='$desc';";
729
                        $ds = mysqli_query($sqlParser->conn, $query);
730
                        if ($ds) {
731
                            $row = mysqli_fetch_assoc($ds);
732
                            $id = $row["id"];
733
                            $_events = implode("','", $events);
734
                            // add new events
735
                            $sql = "INSERT IGNORE INTO $dbase.`" . $table_prefix . "site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`" . $table_prefix . "system_eventnames` se WHERE name IN ('{$_events}')";
736
                            mysqli_query($sqlParser->conn, $sql);
737
                            // remove absent events
738
                            $sql = "DELETE `pe` FROM {$dbase}.`{$table_prefix}site_plugin_events` `pe` LEFT JOIN {$dbase}.`{$table_prefix}system_eventnames` `se` ON `pe`.`evtid`=`se`.`id` AND `name` IN ('{$_events}') WHERE ISNULL(`name`) AND `pluginid` = {$id}";
739
                            mysqli_query($sqlParser->conn, $sql);
740
                        }
741
                    }
742
                }
743
            } else {
744
                $installDataLevel['plugins'][$modulePlugin[0]]['type'] = 'skip';