From 31687d685643b368975a27770d16f5e3c2e596f4 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Thu, 24 Sep 2020 09:37:49 +0800 Subject: [PATCH] * Finish task #8009. --- module/bug/model.php | 18 +++++++++++++----- module/bug/view/create.html.php | 3 ++- module/user/view/ajaxprinttemplates.html.php | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index 1c058874f7..90dea07ab5 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -106,10 +106,18 @@ class bugModel extends model */ public function create($from = '') { - /* Delete template HTML tags, line breaks and spaces and tags in the steps. */ - $stepTemplate = strip_tags($this->lang->bug->tplStep . $this->lang->bug->tplResult . $this->lang->bug->tplExpect); - $steps = strip_tags(preg_replace("/\s/", "", $this->post->steps)); - $steps = str_replace(" ", "", $steps); + /* Delete HTML tags, line breaks, and spaces in templates and steps. */ + if($this->post->templateID) + { + $stepsTemplate = strip_tags($this->dao->select('content')->from(TABLE_USERTPL)->where('id')->eq($this->post->templateID)->fetch('content')); + $stepsTemplate = preg_replace("/\s/", "", $stepsTemplate); + } + else + { + $stepsTemplate = strip_tags($this->lang->bug->tplStep . $this->lang->bug->tplResult . $this->lang->bug->tplExpect); + } + $steps = strip_tags(preg_replace("/\s/", "", $this->post->steps)); + $steps = str_replace(" ", "", $steps); $now = helper::now(); $bug = fixer::input('post') @@ -123,7 +131,7 @@ class bugModel extends model ->setIF($this->post->assignedTo != '', 'assignedDate', $now) ->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story)) ->setIF(strpos($this->config->bug->create->requiredFields, 'project') !== false, 'project', $this->post->project) - ->setIF($steps == $stepTemplate, 'steps', '') + ->setIF($steps == $stepsTemplate, 'steps', '') ->stripTags($this->config->bug->editor->create['id'], $this->config->allowedTags) ->cleanInt('product,project,module,severity') ->join('openedBuild', ',') diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php index 7450eb4f50..c41d99241a 100644 --- a/module/bug/view/create.html.php +++ b/module/bug/view/create.html.php @@ -219,9 +219,10 @@ js::set('flow', $config->global->flow); bug->steps;?> - + fetch('user', 'ajaxPrintTemplates', 'type=bug&link=steps');?> + '].edit.cmd; editor[''].html(''); cmd.inserthtml(content); + $("#mainContent #dataform .table.table-form .steps #templateID").attr("value", templateID); } function deleteTemplate(templateID)