getPluginDetails($pluginFile); if ($details) { $oPluginRegistry->disablePlugin($details->getNamespace()); $oPluginRegistry->savePlugin($details->getNamespace()); G::auditLog("DisablePlugin", "Plugin Name: " . $details->getNamespace()); return ['success' => true, 'action' => 'disabled', 'plugin' => $details->getNamespace()]; } } else { // Habilitar plugin if ($pluginDirPath && is_dir($pluginDirPath)) { require_once($pluginFilePath); $details = $oPluginRegistry->getPluginDetails($pluginFile); if ($details) { $oPluginRegistry->enablePlugin($details->getNamespace()); $oPluginRegistry->setupPlugins(); $oPluginRegistry->savePlugin($details->getNamespace()); G::auditLog("EnablePlugin", "Plugin Name: " . $details->getNamespace()); return ['success' => true, 'action' => 'enabled', 'plugin' => $details->getNamespace()]; } } else { throw new FileNotFoundException('Plugin directory not found'); } } return ['success' => false, 'error' => 'Plugin operation failed']; } catch (Exception $e) { G::auditLog('PluginChange', 'Error: ' . $e->getMessage()); return ['success' => false, 'error' => $e->getMessage()]; } } // Ejecutar y devolver respuesta JSON try { $result = handlePluginChange(); header('Content-Type: application/json'); echo json_encode($result); } catch (Exception $e) { header('Content-Type: application/json'); http_response_code(400); echo json_encode(['success' => false, 'error' => 'Invalid request']); }