This commit is contained in:
Kevin Feiler
2025-10-16 03:39:52 +02:00
parent dccf4b1b4e
commit f5cf6ee08f
2 changed files with 418 additions and 7 deletions

View File

@@ -177,8 +177,8 @@ function keyhelpmanager_CreateAccount(array $params)
"display_name" => $clientName,
];
// Use template if selected
if (!empty($templateId)) {
// Use template if selected (skip if manual or empty)
if (!empty($templateId) && $templateId !== "manual") {
$accountData["plan_id"] = $templateId;
}
@@ -202,7 +202,8 @@ function keyhelpmanager_CreateAccount(array $params)
// Create domain with template settings
$domainData = ["domain_name" => $domain, "user_id" => $userId];
if (!empty($templateId)) {
// Only add template_id if it's set and not manual mode
if (!empty($templateId) && $templateId !== "manual") {
$domainData["template_id"] = $templateId;
}
@@ -307,7 +308,6 @@ function keyhelpmanager_TerminateAccount(array $params)
function keyhelpmanager_ClientArea(array $params)
{
try {
$accountDetails = _keyhelpmanager_GetAccountDetails(
$params["serviceid"],
);
@@ -315,6 +315,11 @@ function keyhelpmanager_ClientArea(array $params)
$domainId = $accountDetails["domainid"] ?? null;
$templateId = $accountDetails["template"] ?? null;
// Don't display template if manual mode
if ($templateId === "manual" || empty($templateId)) {
$templateId = null;
}
$hostname = $params["serverhostname"] ?? "";
$useSSL = $params["serversecure"] ?? "on";
$protocol = $useSSL === "on" ? "https" : "http";
@@ -729,17 +734,36 @@ function _keyhelpmanager_GetTemplates($params = null)
}
// Fetch templates/plans from KeyHelp
// Note: This endpoint may not exist in all KeyHelp versions
$result = _keyhelpmanager_APIRequest($apiParams, "/plans", "GET");
if (!$result["success"]) {
// If /plans endpoint doesn't exist, provide manual template option
if (strpos($result["error"], "Endpoint not found") !== false ||
strpos($result["error"], "404") !== false) {
logActivity(
"KeyHelpManager: /plans endpoint not available - using manual template mode",
);
return [
"" => "-- No Template (Manual Config) --",
"manual" => "Manual Configuration (No Template)",
];
}
logActivity(
"KeyHelpManager: Failed to fetch templates - " .
$result["error"],
);
return ["" => "-- Error loading templates --"];
return [
"" => "-- No Template (API Error) --",
"manual" => "Manual Configuration (No Template)",
];
}
$templates = ["" => "-- Select Template --"];
$templates = [
"" => "-- Select Template --",
"manual" => "Manual Configuration (No Template)",
];
if (isset($result["data"]) && is_array($result["data"])) {
foreach ($result["data"] as $template) {
@@ -765,7 +789,10 @@ function _keyhelpmanager_GetTemplates($params = null)
logActivity(
"KeyHelpManager: Get templates failed - " . $e->getMessage(),
);
return ["" => "-- Error: " . $e->getMessage() . " --"];
return [
"" => "-- No Template (Error) --",
"manual" => "Manual Configuration (No Template)",
];
}
}