* Finish task #68709: delete VM template.

This commit is contained in:
wangjianhua
2022-09-19 14:09:10 +08:00
parent 330a995630
commit fc7f0e6e64
7 changed files with 45 additions and 1 deletions
+39
View File
@@ -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.
*