From fc7f0e6e643e4fc7253ee15c90d67eec689b1391 Mon Sep 17 00:00:00 2001 From: wangjianhua Date: Mon, 19 Sep 2022 14:09:10 +0800 Subject: [PATCH] * Finish task #68709: delete VM template. --- module/zahost/control.php | 39 ++++++++++++++++++++++ module/zahost/lang/de.php | 1 + module/zahost/lang/en.php | 1 + module/zahost/lang/fr.php | 1 + module/zahost/lang/vi.php | 1 + module/zahost/lang/zh-cn.php | 1 + module/zahost/view/browsetemplate.html.php | 2 +- 7 files changed, 45 insertions(+), 1 deletion(-) diff --git a/module/zahost/control.php b/module/zahost/control.php index f9b4f2d98b..f016d936e2 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -198,6 +198,45 @@ class zahost extends control $this->display(); } + /** + * Delete host. + * + * @param int $templateID + * @param string $confirm + * @access public + * @return void + */ + public function deleteTemplate($templateID, $confirm = 'no') + { + if($confirm == 'no') + { + die(js::confirm($this->lang->zahost->confirmDelete, inlink('deleteTemplate', "templateID=$templateID&confirm=yes"))); + } + + $template = $this->zahost->getTemplateById($templateID); + $this->dao->delete()->from(TABLE_VMTEMPLATE)->where('id')->eq($templateID)->exec(); + $this->loadModel('action')->create('vmtemplate', $templateID, 'deleted'); + + /* if ajax request, send result. */ + if($this->server->ajax) + { + if(dao::isError()) + { + $response['result'] = 'fail'; + $response['message'] = dao::getError(); + } + else + { + $response['result'] = 'success'; + $response['message'] = ''; + } + $this->send($response); + } + + if(isonlybody())die(js::reload('parent.parent')); + die(js::locate($this->createLink('zahost', 'browsetemplate', "hostID={$template->hostID}"), 'parent')); + } + /* * Browse VM template. * diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 4784619bf9..193696d429 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -13,6 +13,7 @@ $lang->zahost->all = 'All'; $lang->zahost->browseTemplate = 'Template Browse'; $lang->zahost->createTemplate = 'Create Template'; $lang->zahost->editTemplate = 'Edit Template'; +$lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 4784619bf9..193696d429 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -13,6 +13,7 @@ $lang->zahost->all = 'All'; $lang->zahost->browseTemplate = 'Template Browse'; $lang->zahost->createTemplate = 'Create Template'; $lang->zahost->editTemplate = 'Edit Template'; +$lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 2698fadefe..79e39d06cb 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -13,6 +13,7 @@ $lang->zahost->all = 'Tous les hôtes'; $lang->zahost->browseTemplate = 'Template Browse'; $lang->zahost->createTemplate = 'Create Template'; $lang->zahost->editTemplate = 'Edit Template'; +$lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Nom'; $lang->zahost->IP = 'IP'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 66891f0c9f..c5a54a5643 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -13,6 +13,7 @@ $lang->zahost->all = 'All'; $lang->zahost->browseTemplate = 'Template Browse'; $lang->zahost->createTemplate = 'Create Template'; $lang->zahost->editTemplate = 'Edit Template'; +$lang->zahost->deleteTemplate = 'Delete Template'; $lang->zahost->name = 'Name'; $lang->zahost->IP = 'IP'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index ab09754089..18fef58d96 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -13,6 +13,7 @@ $lang->zahost->all = '所有主机'; $lang->zahost->browseTemplate = '虚拟机模板列表'; $lang->zahost->createTemplate = '创建虚拟机模板'; $lang->zahost->editTemplate = '编辑虚拟机模板'; +$lang->zahost->deleteTemplate = '删除虚拟机模板'; $lang->zahost->name = '名称'; $lang->zahost->IP = 'IP'; diff --git a/module/zahost/view/browsetemplate.html.php b/module/zahost/view/browsetemplate.html.php index 147483067d..2ca98ad271 100755 --- a/module/zahost/view/browsetemplate.html.php +++ b/module/zahost/view/browsetemplate.html.php @@ -65,7 +65,7 @@ zahost->langList, $template->osLang);?> id}", $template, 'list', 'edit');?> - createLink('zahost', 'delete', "id={$template->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");;?> + createLink('zahost', 'deleteTemplate', "id={$template->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");?>