From 7676814eb976c2e454453d3365acd79822377a25 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Fri, 11 May 2012 04:37:46 +0200 Subject: [PATCH] Add suspend/unsuspend page --- frontend/module.admin.container.suspend.php | 66 +++++++++++++++++++ frontend/module.admin.overview.php | 16 +++++ .../templates/admin.container.suspend.tpl | 14 ++++ frontend/templates/admin.overview.tpl | 3 + 4 files changed, 99 insertions(+) create mode 100644 frontend/module.admin.container.suspend.php create mode 100644 frontend/module.admin.overview.php create mode 100644 frontend/templates/admin.container.suspend.tpl create mode 100644 frontend/templates/admin.overview.tpl diff --git a/frontend/module.admin.container.suspend.php b/frontend/module.admin.container.suspend.php new file mode 100644 index 0000000..2fe2d29 --- /dev/null +++ b/frontend/module.admin.container.suspend.php @@ -0,0 +1,66 @@ +RequireAccessLevel(20); + + $sContainer = new Container($router->uParameters[1]); + + $sSuspended = ($sContainer->sStatus == CVM_STATUS_SUSPENDED) ? true : false; + + if(isset($_POST['submit'])) + { + if($_POST['action'] == "suspend") + { + $sContainer->Suspend(); + + $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCES, "Container suspended", "The container has been suspended and can no longer be used by the owner."); + $sMainContents .= $err->Render(); + } + elseif($_POST['action'] == "unsuspend") + { + $sContainer->Unsuspend(); + + $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCES, "Container unsuspended", "The container has been unsuspended and can now be used by the owner again."); + $sMainContents .= $err->Render(); + } + } + + $sPageContents = Templater::InlineRender("admin.container.suspend", $locale->strings, array( + 'id' => $sContainer->sId, + 'suspended' => $sSuspended + )); +} +catch (InsufficientAccessLevelException $e) +{ + $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "You are not authorized to view this page", "Your access level is not sufficient."); + $sMainContents .= $err->Render(); +} +catch (NotFoundException $e) +{ + $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Container not found", "The container you selected was not found."); + $sMainContents .= $err->Render(); +} +catch (ContainerSuspendException $e) +{ + $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Failed to suspend container", "The container could not be suspended."); + $sMainContents .= $err->Render(); +} +catch (ContainerUnsuspendException $e) +{ + $err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Failed to unsuspend container", "The container could not be unsuspended."); + $sMainContents .= $err->Render(); +} diff --git a/frontend/module.admin.overview.php b/frontend/module.admin.overview.php new file mode 100644 index 0000000..649ec0e --- /dev/null +++ b/frontend/module.admin.overview.php @@ -0,0 +1,16 @@ +strings, array()); diff --git a/frontend/templates/admin.container.suspend.tpl b/frontend/templates/admin.container.suspend.tpl new file mode 100644 index 0000000..f827804 --- /dev/null +++ b/frontend/templates/admin.container.suspend.tpl @@ -0,0 +1,14 @@ +
+ <%if suspended == false> +

<%!title-admin-vps-suspend>

+

<%!vps-admin-suspend-text>

+ + + <%/if><%if suspended == true> +

<%!title-admin-vps-unsuspend>

+

<%!vps-admin-unsuspend-text>

+ + + <%/if> +
+ diff --git a/frontend/templates/admin.overview.tpl b/frontend/templates/admin.overview.tpl new file mode 100644 index 0000000..090fedd --- /dev/null +++ b/frontend/templates/admin.overview.tpl @@ -0,0 +1,3 @@ +

<%!title-admin-overview>

+ +

<%!admin-overview-message>