$id_plugin ], 'id_agente_modulo' ); $ret = []; foreach ($plugin_modules as $id) { try { $module = new PandoraFMS\Module($id); $module->delete(); } catch (Exception $e) { $ret[] = __('Failed to erase module %d: %s', $id, $e->getMessage()); } } if (enterprise_installed() === true) { enterprise_include_once('include/functions_policies.php'); $policies_ids = db_get_all_rows_filter( 'tpolicy_modules', ['id_plugin' => $id_plugin], 'id' ); foreach ($policies_ids as $id) { if (policies_change_delete_pending_module($id) !== true) { $ret[] = __('Failed to erase policy module: %d', $id); } } } return $ret; } /** * Effectively remove a plugin from the system. * * @param integer $id_plugin Plugin id. * * @return array Of errors, empty if no errors. */ function plugins_delete_plugin(int $id_plugin) { $result = []; $problem = plugins_remove_modules($id_plugin) !== true; if (empty($problem) !== false) { $result = $problem; } // Remove all components related to this plugin. db_process_sql_delete( 'tnetwork_component', [ 'id_plugin' => $id_plugin ] ); if (is_metaconsole() === true && is_management_allowed() === true) { $sc = new Synchronizer(); $problems = $sc->apply( function ($node) use ($id_plugin) { $rt = []; try { $node->connect(); $rt = plugins_remove_modules($id_plugin); $node->disconnect(); } catch (Exception $e) { $rt[] = $e->getMessage(); } return $rt; }, false ); foreach ($problems as $prob) { $result = array_merge($result, $prob); } } return $result; }