Jump to content

provisioning model - clientarea confirm reboot server


Recommended Posts

Hello , Iam devloping a provisioning module and I need to add a client area command for 'reboot' the server  but I need to it to be confirmed from the client before running the reboot (becuase If I add the reboot command into ClientAreaCustomButtonArray it will work fine and reboot the server but without confirmation) command, I do the following but the module did not run the reboot command:

in module file I added

function gatehubopenstackwcservers_ClientAreaCustomButtonArray()
{
    $buttonarray = array(
        "Reboot Server" => "confirmReboot",
    );
    return $buttonarray;
}

function gatehubopenstackwcservers_confirmReboot($params)
{
    $serviceId = $params['serviceid'];
    $userId = $params['userid'];

    // Display a confirmation form using WHMCS template functions
    return array(
        'templatefile' => 'templates/confirmation_reboot_server',  // Assuming a custom template file
        'vars' => array(
            'serviceId' => $serviceId,
            'userId' => $userId
        )
    );
}


function gatehubopenstackwcservers_reboot($params)
{

   
    $server_state = rebootServer($params['serviceid'], $params);
    if (isset($server_state['error'])) {
        logActivity("error rebooting server service ID: {$params['serviceid']}, {$server_state['error']}", $params['userid']);
        $result = $server_state['error'];
    } else {
        $result = "success";
        logActivity("server rebooted service ID: {$params['serviceid']}", $params['userid']);
    }
    return  $result;
}

in my module 'templates/confirmation_reboot_server.tpl' I added:

<form action="clientarea.php?action=productdetails" method="post">
    <input type="hidden" name="id" value="{$serviceId}" />
    <input type="hidden" name="modop" value="custom" />
    <input type="hidden" name="a" value="reboot" />
    <input type="hidden" name="userid" value="{$userId}">
    <p>Are you sure you want to reboot the server with service ID {$serviceId}?</p>
    <button type="submit">Yes, Reboot Server</button>
</form>


When I logged in as client and goto service and try to reboot , the confirmation form show and ask me to confirm , when I confirm nothing happed and it just redirect me to the product page and show the product info , without real running of `gatehubopenstackwcservers_reboot()` function.

Any help appreciated

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated