From 3e86bf4da9443484ccf198510596e2041b74e822 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Thu, 12 Aug 2021 16:14:56 +0800 Subject: [PATCH] * Finish task #41226. --- db/update15.3.sql | 2 + db/zentao.sql | 2 + module/message/config.php | 3 + module/message/model.php | 11 ++ module/projectrelease/control.php | 27 ++- module/projectrelease/css/create.css | 1 + module/projectrelease/css/edit.css | 1 + module/projectrelease/model.php | 20 +++ module/projectrelease/view/create.html.php | 12 ++ module/projectrelease/view/edit.html.php | 12 ++ module/release/control.php | 13 +- module/release/css/create.css | 1 + module/release/css/edit.css | 1 + module/release/lang/de.php | 8 + module/release/lang/en.php | 8 + module/release/lang/fr.php | 8 + module/release/lang/vi.php | 8 + module/release/lang/zh-cn.php | 8 + module/release/model.php | 158 ++++++++++++++++++ module/release/view/create.html.php | 12 ++ module/release/view/edit.html.php | 12 ++ module/release/view/sendmail.html.php | 35 ++++ .../module/message/ext/config/xuanxuan.php | 11 +- 23 files changed, 361 insertions(+), 13 deletions(-) create mode 100644 module/projectrelease/css/create.css create mode 100644 module/release/css/create.css create mode 100644 module/release/view/sendmail.html.php diff --git a/db/update15.3.sql b/db/update15.3.sql index 743ccea4e4..1beb37b17f 100644 --- a/db/update15.3.sql +++ b/db/update15.3.sql @@ -1 +1,3 @@ ALTER TABLE `zt_testtask` ADD `realFinishedDate` datetime NOT NULL AFTER `end`; +ALTER TABLE `zt_release` ADD `mailto` text AFTER `desc`; +ALTER TABLE `zt_release` ADD `notify` varchar(255) AFTER `mailto`; diff --git a/db/zentao.sql b/db/zentao.sql index ab4f9f3beb..3c52e1c806 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -768,6 +768,8 @@ CREATE TABLE IF NOT EXISTS `zt_release` ( `bugs` text NOT NULL, `leftBugs` text NOT NULL, `desc` text NOT NULL, + `mailto` text, + `notify` varchar(255), `status` varchar(20) NOT NULL default 'normal', `subStatus` varchar(30) NOT NULL default '', `deleted` enum('0','1') NOT NULL default '0', diff --git a/module/message/config.php b/module/message/config.php index d39fb726e9..6cd71ac977 100644 --- a/module/message/config.php +++ b/module/message/config.php @@ -10,6 +10,7 @@ $config->message->objectTypes['case'] = array('opened', 'edited', 'commen $config->message->objectTypes['testtask'] = array('opened', 'edited', 'started', 'blocked', 'closed', 'activated'); $config->message->objectTypes['todo'] = array('opened', 'edited'); $config->message->objectTypes['doc'] = array('created', 'edited'); +$config->message->objectTypes['release'] = array('opened', 'edited'); $config->message->available = array(); $config->message->available['mail']['story'] = $config->message->objectTypes['story']; @@ -17,6 +18,7 @@ $config->message->available['mail']['task'] = $config->message->objectTypes[ $config->message->available['mail']['bug'] = $config->message->objectTypes['bug']; $config->message->available['mail']['testtask'] = array('opened', 'edited', 'closed'); $config->message->available['mail']['doc'] = $config->message->objectTypes['doc']; +$config->message->available['mail']['release'] = $config->message->objectTypes['release']; $config->message->available['webhook'] = $config->message->objectTypes; @@ -26,6 +28,7 @@ $config->message->available['message']['task'] = $config->message->objectTyp $config->message->available['message']['testtask'] = $config->message->objectTypes['testtask']; $config->message->available['message']['todo'] = $config->message->objectTypes['todo']; $config->message->available['message']['doc'] = $config->message->objectTypes['doc']; +$config->message->available['message']['release'] = $config->message->objectTypes['release']; $config->message->typeLink = array(); $config->message->typeLink['mail'] = 'mail|index'; diff --git a/module/message/model.php b/module/message/model.php index 60c375ef8c..c8cfb2baad 100644 --- a/module/message/model.php +++ b/module/message/model.php @@ -164,6 +164,17 @@ class messageModel extends model if(empty($toList) and $objectType == 'todo') $toList = $object->account; if(empty($toList) and $objectType == 'testtask') $toList = $object->owner; if(empty($toList) and $objectType == 'meeting') $toList = $object->host . $object->participant; + if(empty($toList) and $objectType == 'release') + { + /* Get notifiy persons. */ + $notifyPersons = array(); + if(!empty($toList->notify)) $notifyPersons = $this->loadModel('release')->getNotifyPersons($object->notify, $object->product, $object->build); + + foreach($notifyPersons as $account) + { + if(strpos($object->mailto . ',', ",{$account},") === false) $toList .= ',' . $account; + } + } if($toList == 'closed') $toList = ''; return $toList; diff --git a/module/projectrelease/control.php b/module/projectrelease/control.php index 33e567de47..71380e8af9 100644 --- a/module/projectrelease/control.php +++ b/module/projectrelease/control.php @@ -98,6 +98,8 @@ class projectrelease extends control */ public function create($projectID) { + /* Load module and config. */ + $this->loadModel('build'); $this->app->loadConfig('release'); $this->config->projectrelease->create = $this->config->release->create; @@ -114,9 +116,7 @@ class projectrelease extends control } /* Get the builds that can select. */ - $productPairs = $this->loadModel('product')->getProductPairsByProject($projectID); - $productIdList = array_keys($productPairs); - $builds = $this->loadModel('build')->getProductBuildPairs($productIdList, 0, 0, 'notrunk'); + $builds = $this->build->getProjectBuildPairs($projectID, 0, 0, 'notrunk|withbranch'); $releaseBuilds = $this->projectrelease->getReleaseBuilds($projectID); foreach($releaseBuilds as $build) unset($builds[$build]); unset($builds['trunk']); @@ -128,6 +128,7 @@ class projectrelease extends control $this->view->position[] = $this->lang->release->create; $this->view->builds = $builds; $this->view->lastRelease = $this->projectrelease->getLast($projectID); + $this->view->users = $this->loadModel('user')->getPairs('noletter|noclosed'); $this->display(); } @@ -140,6 +141,10 @@ class projectrelease extends control */ public function edit($releaseID) { + /* Load module and config. */ + $this->loadModel('story'); + $this->loadModel('bug'); + $this->loadModel('build'); $this->app->loadConfig('release'); $this->config->projectrelease->create = $this->config->release->create; @@ -158,15 +163,21 @@ class projectrelease extends control $this->executeHooks($releaseID); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID"))); } - $this->loadModel('story'); - $this->loadModel('bug'); - $this->loadModel('build'); /* Get release and build. */ $release = $this->projectrelease->getById((int)$releaseID); $this->commonAction($release->project, $release->product, $release->branch); $build = $this->build->getById($release->build); + /* Get the builds that can select. */ + $builds = $this->build->getProjectBuildPairs($release->project, $release->product, $release->branch, 'notrunk|withbranch'); + $releaseBuilds = $this->projectrelease->getReleaseBuilds($release->project); + foreach($releaseBuilds as $releaseBuild) + { + if($releaseBuild != $build->id) unset($builds[$releaseBuild]); + } + unset($builds['trunk']); + /* Set project menu. */ $this->project->setMenu($release->project); @@ -174,7 +185,9 @@ class projectrelease extends control $this->view->position[] = $this->lang->release->edit; $this->view->release = $release; $this->view->build = $build; - $this->view->builds = $this->loadModel('build')->getProjectBuildPairs($release->project, $release->product, $release->branch, 'notrunk|withbranch'); + $this->view->builds = $builds; + $this->view->users = $this->loadModel('user')->getPairs('noletter|noclosed'); + $this->display(); } diff --git a/module/projectrelease/css/create.css b/module/projectrelease/css/create.css new file mode 100644 index 0000000000..5878d6c75f --- /dev/null +++ b/module/projectrelease/css/create.css @@ -0,0 +1 @@ +.checkbox-primary {display: inline-block; margin-left: 10px;} diff --git a/module/projectrelease/css/edit.css b/module/projectrelease/css/edit.css index 76ca9a7478..dec7f697cc 100644 --- a/module/projectrelease/css/edit.css +++ b/module/projectrelease/css/edit.css @@ -1,3 +1,4 @@ .table-form > tbody > tr > td > .row > [class*="col-"] .panel-heading {line-height: 16px;} .contentDiv {height: 190px; overflow-y: auto; margin-bottom: 10px !important;} .contentDiv .panel-heading {line-height: 14px;} +.checkbox-primary {display: inline-block; margin-left: 10px;} diff --git a/module/projectrelease/model.php b/module/projectrelease/model.php index e252327854..46eb6c0aae 100644 --- a/module/projectrelease/model.php +++ b/module/projectrelease/model.php @@ -102,6 +102,7 @@ class projectreleaseModel extends model */ public function create() { + /* Init vars. */ $productID = $this->post->product; $branch = $this->post->branch; $buildID = 0; @@ -126,6 +127,8 @@ class projectreleaseModel extends model ->setDefault('stories', '') ->join('stories', ',') ->join('bugs', ',') + ->join('mailto', ',') + ->join('notify', ',') ->setIF($this->post->build == false, 'build', $buildID) ->setIF($productID, 'product', $productID) ->setIF($branch, 'branch', $branch) @@ -213,16 +216,20 @@ class projectreleaseModel extends model */ public function update($releaseID) { + /* Init vars. */ $releaseID = (int)$releaseID; $oldRelease = $this->dao->select('*')->from(TABLE_RELEASE)->where('id')->eq($releaseID)->fetch(); $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq((int)$this->post->build)->fetch('branch'); $release = fixer::input('post')->stripTags($this->config->release->editor->edit['id'], $this->config->allowedTags) ->add('branch', (int)$branch) + ->join('mailto', ',') + ->join('notify', ',') ->setIF(!$this->post->marker, 'marker', 0) ->cleanInt('product') ->remove('files,labels,allchecker,uid') ->get(); + $release = $this->loadModel('file')->processImgURL($release, $this->config->release->editor->edit['id'], $this->post->uid); $this->dao->update(TABLE_RELEASE)->data($release) ->autoCheck() @@ -315,4 +322,17 @@ class projectreleaseModel extends model $this->loadModel('action'); foreach($this->post->bugs as $bugID) $this->action->create('bug', $bugID, 'linked2release', '', $releaseID); } + + /** + * Send mail. + * + * @param int $releaseID + * @param int $actionID + * @access public + * @return void + */ + public function sendmail($releaseID, $actionID) + { + $this->loadModel('release')->sendmail($releaseID, $actionID); + } } diff --git a/module/projectrelease/view/create.html.php b/module/projectrelease/view/create.html.php index 174c83ec00..254435a174 100644 --- a/module/projectrelease/view/create.html.php +++ b/module/projectrelease/view/create.html.php @@ -59,6 +59,18 @@ release->desc;?> + + release->notify;?> + release->notifyList);?> + + + release->mailto;?> + +
+ chooseUsersToMail}' multiple");?> +
+ + files;?> fetch('file', 'buildform');?> diff --git a/module/projectrelease/view/edit.html.php b/module/projectrelease/view/edit.html.php index bf94003bc4..e195cc8f4d 100644 --- a/module/projectrelease/view/edit.html.php +++ b/module/projectrelease/view/edit.html.php @@ -52,6 +52,18 @@ release->desc;?> desc), "rows=10 class='form-control kindeditor' hidefocus='true'");?> + + release->notify;?> + release->notifyList, $release->notify);?> + + + release->mailto;?> + +
+ mailto, "class='form-control chosen' data-placeholder='{$lang->chooseUsersToMail}' multiple");?> +
+ + files;?> fetch('file', 'buildform');?> diff --git a/module/release/control.php b/module/release/control.php index 76f0d2f213..c90635efaa 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -85,7 +85,9 @@ class release extends control $this->view->position[] = $this->lang->release->create; $this->view->productID = $productID; $this->view->builds = $builds; + $this->view->users = $this->loadModel('user')->getPairs('noletter|noclosed'); $this->view->lastRelease = $this->release->getLast($productID, $branch); + $this->display(); } @@ -122,11 +124,20 @@ class release extends control $this->commonAction($release->product, $release->branch); $build = $this->build->getById($release->build); + $builds = $this->loadModel('build')->getProductBuildPairs($release->product, $release->branch, 'notrunk|withbranch', false); + $releaseBuilds = $this->release->getReleaseBuilds($release->product, $release->branch); + foreach($releaseBuilds as $releaseBuild) + { + if($releaseBuild != $build->id) unset($builds[$releaseBuild]); + } + unset($builds['trunk']); + $this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->release->edit; $this->view->position[] = $this->lang->release->edit; $this->view->release = $release; $this->view->build = $build; - $this->view->builds = $this->loadModel('build')->getProductBuildPairs($release->product, $release->branch, 'notrunk|withbranch', false); + $this->view->builds = $builds; + $this->view->users = $this->loadModel('user')->getPairs('noletter|noclosed'); $this->display(); } diff --git a/module/release/css/create.css b/module/release/css/create.css new file mode 100644 index 0000000000..5878d6c75f --- /dev/null +++ b/module/release/css/create.css @@ -0,0 +1 @@ +.checkbox-primary {display: inline-block; margin-left: 10px;} diff --git a/module/release/css/edit.css b/module/release/css/edit.css index 76ca9a7478..dec7f697cc 100644 --- a/module/release/css/edit.css +++ b/module/release/css/edit.css @@ -1,3 +1,4 @@ .table-form > tbody > tr > td > .row > [class*="col-"] .panel-heading {line-height: 16px;} .contentDiv {height: 190px; overflow-y: auto; margin-bottom: 10px !important;} .contentDiv .panel-heading {line-height: 14px;} +.checkbox-primary {display: inline-block; margin-left: 10px;} diff --git a/module/release/lang/de.php b/module/release/lang/de.php index 7ad42950d8..031c95cf46 100644 --- a/module/release/lang/de.php +++ b/module/release/lang/de.php @@ -56,6 +56,8 @@ $lang->release->createdBugs = 'Erstellte %s Bugs'; $lang->release->export = 'Export as HTML'; $lang->release->yesterday = 'Gestern veröffentlicht'; $lang->release->all = 'All'; +$lang->release->notify = 'Notify'; +$lang->release->mailto = 'Mailto'; $lang->release->filePath = 'Download : '; $lang->release->scmPath = 'SCM Pfad : '; @@ -74,3 +76,9 @@ $lang->release->changeStatusList['terminate'] = 'Terminiert'; $lang->release->action = new stdclass(); $lang->release->action->changestatus = array('main' => '$date, 由 $actor $extra。', 'extra' => 'changeStatusList'); + +$lang->release->notifyList['PO'] = "{$lang->productCommon} Owner"; +$lang->release->notifyList['QD'] = 'QA Manager'; +$lang->release->notifyList['SC'] = 'Story Creator'; +$lang->release->notifyList['ET'] = "{$lang->execution->common} Team Members"; +$lang->release->notifyList['PT'] = "Project Team Members"; diff --git a/module/release/lang/en.php b/module/release/lang/en.php index 614f409cc5..a77a316989 100644 --- a/module/release/lang/en.php +++ b/module/release/lang/en.php @@ -56,6 +56,8 @@ $lang->release->createdBugs = 'Unresolved %s Bug'; $lang->release->export = 'Export as HTML'; $lang->release->yesterday = 'Released Yesterday'; $lang->release->all = 'All'; +$lang->release->notify = 'Notify'; +$lang->release->mailto = 'Mailto'; $lang->release->filePath = 'Download : '; $lang->release->scmPath = 'SCM Path : '; @@ -74,3 +76,9 @@ $lang->release->changeStatusList['terminate'] = 'Terminated'; $lang->release->action = new stdclass(); $lang->release->action->changestatus = array('main' => '$date, $extra by $actor', 'extra' => 'changeStatusList'); + +$lang->release->notifyList['PO'] = "{$lang->productCommon} Owner"; +$lang->release->notifyList['QD'] = 'QA Manager'; +$lang->release->notifyList['SC'] = 'Story Creator'; +$lang->release->notifyList['ET'] = "{$lang->execution->common} Team Members"; +$lang->release->notifyList['PT'] = "Project Team Members"; diff --git a/module/release/lang/fr.php b/module/release/lang/fr.php index 794a18a0cb..ffc16ca3dc 100644 --- a/module/release/lang/fr.php +++ b/module/release/lang/fr.php @@ -56,6 +56,8 @@ $lang->release->createdBugs = '%s Bugs non résolus'; $lang->release->export = 'Export HTML'; $lang->release->yesterday = 'Versionné Hier'; $lang->release->all = 'Tout'; +$lang->release->notify = 'Notify'; +$lang->release->mailto = 'Mailto'; $lang->release->filePath = 'Télecharger : '; $lang->release->scmPath = 'SCM Path : '; @@ -74,3 +76,9 @@ $lang->release->changeStatusList['terminate'] = 'Terminée'; $lang->release->action = new stdclass(); $lang->release->action->changestatus = array('main' => '$date, $extra par $actor', 'extra' => 'changeStatusList'); + +$lang->release->notifyList['PO'] = "{$lang->productCommon} Owner"; +$lang->release->notifyList['QD'] = 'QA Manager'; +$lang->release->notifyList['SC'] = 'Story Creator'; +$lang->release->notifyList['ET'] = "{$lang->execution->common} Team Members"; +$lang->release->notifyList['PT'] = "Project Team Members"; diff --git a/module/release/lang/vi.php b/module/release/lang/vi.php index 57607a8d2a..8d273a0dac 100644 --- a/module/release/lang/vi.php +++ b/module/release/lang/vi.php @@ -56,6 +56,8 @@ $lang->release->createdBugs = 'Bug %s chưa được giải quyết'; $lang->release->export = 'Xuất ra HTML'; $lang->release->yesterday = 'Phát hành hôm qua'; $lang->release->all = 'Tất cả'; +$lang->release->notify = 'Notify'; +$lang->release->mailto = 'Mailto'; $lang->release->filePath = 'Tải về : '; $lang->release->scmPath = 'SCM Path : '; @@ -74,3 +76,9 @@ $lang->release->changeStatusList['terminate'] = 'Hoàn thành'; $lang->release->action = new stdclass(); $lang->release->action->changestatus = array('main' => '$date, $extra bởi $actor', 'extra' => 'changeStatusList'); + +$lang->release->notifyList['PO'] = "{$lang->productCommon} Owner"; +$lang->release->notifyList['QD'] = 'QA Manager'; +$lang->release->notifyList['SC'] = 'Story Creator'; +$lang->release->notifyList['ET'] = "{$lang->execution->common} Team Members"; +$lang->release->notifyList['PT'] = "Project Team Members"; diff --git a/module/release/lang/zh-cn.php b/module/release/lang/zh-cn.php index e108611d91..bcdafcdb9c 100644 --- a/module/release/lang/zh-cn.php +++ b/module/release/lang/zh-cn.php @@ -56,6 +56,8 @@ $lang->release->createdBugs = '本次共遗留 %s 个Bug'; $lang->release->export = '导出HTML'; $lang->release->yesterday = '昨日发布'; $lang->release->all = '所有'; +$lang->release->notify = '通知人员'; +$lang->release->mailto = '抄送给'; $lang->release->filePath = '下载地址:'; $lang->release->scmPath = '版本库地址:'; @@ -74,3 +76,9 @@ $lang->release->changeStatusList['terminate'] = '停止维护'; $lang->release->action = new stdclass(); $lang->release->action->changestatus = array('main' => '$date, 由 $actor $extra。', 'extra' => 'changeStatusList'); + +$lang->release->notifyList['PO'] = "{$lang->productCommon}负责人"; +$lang->release->notifyList['QD'] = '测试负责人'; +$lang->release->notifyList['SC'] = '需求提交人'; +$lang->release->notifyList['ET'] = "所在{$lang->execution->common}团队成员"; +$lang->release->notifyList['PT'] = "所在项目团队成员"; diff --git a/module/release/model.php b/module/release/model.php index 48d9dbac41..e0074e0cb1 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -110,6 +110,7 @@ class releaseModel extends model */ public function create($productID, $branch = 0) { + /* Init vars. */ $productID = (int)$productID; $branch = (int)$branch; $buildID = 0; @@ -126,6 +127,8 @@ class releaseModel extends model ->setDefault('stories', '') ->join('stories', ',') ->join('bugs', ',') + ->join('mailto', ',') + ->join('notify', ',') ->setIF($this->post->build == false, 'build', $buildID) ->stripTags($this->config->release->editor->create['id'], $this->config->allowedTags) ->remove('allchecker,files,labels,uid') @@ -216,16 +219,20 @@ class releaseModel extends model */ public function update($releaseID) { + /* Init vars. */ $releaseID = (int)$releaseID; $oldRelease = $this->dao->select('*')->from(TABLE_RELEASE)->where('id')->eq($releaseID)->fetch(); $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq((int)$this->post->build)->fetch('branch'); $release = fixer::input('post')->stripTags($this->config->release->editor->edit['id'], $this->config->allowedTags) ->add('branch', (int)$branch) + ->join('mailto', ',') + ->join('notify', ',') ->setIF(!$this->post->marker, 'marker', 0) ->cleanInt('product') ->remove('files,labels,allchecker,uid') ->get(); + $release = $this->loadModel('file')->processImgURL($release, $this->config->release->editor->edit['id'], $this->post->uid); /* update release project and branch */ @@ -249,6 +256,67 @@ class releaseModel extends model } } + /** + * Get notify persons. + * + * @param string $notfiyList + * @param int $productID + * @param int $buildID + * @access public + * @return array + */ + public function getNotifyPersons($notifyList = '', $productID = 0, $buildID = 0) + { + if(empty($notifyList)) return array(); + + /* Init vars. */ + $notifyPersons = array(); + $managers = ''; + $notifyList = explode($notifyList, ','); + + foreach($notifyList as $notify) + { + if($notify == 'PO' or $notify == 'QD' or $notify == 'feedback') + { + $managers .= $notify . ','; + } + elseif($notify == 'SC' and !empty($buildID)) + { + $stories = $this->dao->select('stories')->from(TABLE_BUILD)->where('id')->eq($buildID)->fetch('stories'); + $stories = trim($stories, ','); + + if(empty($stories)) continue; + + $createUsers = $this->dao->select('openedBy')->from(TABLE_STORY)->where('id')->in($stories)->fetchPairs(); + $notifyPersons += $createUsers; + } + elseif(($notify == 'ET' or $notify == 'PT') and !empty($buildID)) + { + $type = $notify == 'ET' ? 'execution' : 'project'; + $members = $this->dao->select('t2.account')->from(TABLE_BUILD)->alias('t1') + ->leftJoin(TABLE_TEAM)->alias('t2')->on('t1.' . $type .'=t2.root') + ->where('t2.type')->eq($type) + ->fetchPairs(); + + if(empty($members)) continue; + + $notifyPersons += $members; + } + } + + if(!empty($managers)) + { + $managers = trim($managers, ','); + $managerUsers = $this->dao->select($managers)->from(TABLE_PRODUCT)->where('id')->eq($productID)->fetch(); + foreach($managerUsers as $account) + { + if(!isset($notifyPersons[$account])) $notifyPersons += array($account => $account); + } + } + + return $notifyPersons; + } + /** * Link stories * @@ -405,4 +473,94 @@ class releaseModel extends model $this->dao->update(TABLE_RELEASE)->set('status')->eq($status)->where('id')->eq($releaseID)->exec(); return dao::isError(); } + + /** + * Send mail. + * + * @param int $releaseID + * @param int $actionID + * @access public + * @return void + */ + public function sendmail($releaseID, $actionID) + { + $this->loadModel('mail'); + $release = $this->getByID($releaseID); + $users = $this->loadModel('user')->getPairs('noletter'); + + /* Get action info. */ + $action = $this->loadModel('action')->getById($actionID); + $history = $this->action->getHistory($actionID); + $action->history = isset($history[$actionID]) ? $history[$actionID] : array(); + $action->appendLink = ''; + + /* Get mail content. */ + $modulePath = $this->app->getModulePath($appName = '', 'release'); + $oldcwd = getcwd(); + $viewFile = $modulePath . 'view/sendmail.html.php'; + chdir($modulePath . 'view'); + if(file_exists($modulePath . 'ext/view/sendmail.html.php')) + { + $viewFile = $modulePath . 'ext/view/sendmail.html.php'; + chdir($modulePath . 'ext/view'); + } + ob_start(); + include $viewFile; + foreach(glob($modulePath . 'ext/view/sendmail.*.html.hook.php') as $hookFile) include $hookFile; + $mailContent = ob_get_contents(); + ob_end_clean(); + chdir($oldcwd); + + $sendUsers = $this->getToAndCcList($release); + if(!$sendUsers) return; + list($toList, $ccList) = $sendUsers; + $subject = 'RELEASE #' . $release->id . ' ' . $release->name; + + /* Send it. */ + $this->mail->send($toList, $subject, $mailContent, $ccList); + if($this->mail->isError()) error_log(join("\n", $this->mail->getError())); + } + + /** + * Get toList and ccList. + * + * @param object $release + * @access public + * @return bool|array + */ + public function getToAndCcList($release) + { + /* Set toList and ccList. */ + $toList = $this->app->user->account; + $ccList = $release->mailto . ','; + + /* Get notifiy persons. */ + $notifyPersons = array(); + if(!empty($release->notify)) $notifyPersons = $this->getNotifyPersons($release->notify, $release->product, $release->build); + + foreach($notifyPersons as $account) + { + if(strpos($ccList, ",{$account},") === false) $ccList .= $account . ','; + } + + $ccList = trim($ccList, ','); + + if(empty($toList)) + { + if(empty($ccList)) return false; + if(strpos($ccList, ',') === false) + { + $toList = $ccList; + $ccList = ''; + } + else + { + $commaPos = strpos($ccList, ','); + $toList = substr($ccList, 0, $commaPos); + $ccList = substr($ccList, $commaPos + 1); + } + } + + return array($toList, $ccList); + } } diff --git a/module/release/view/create.html.php b/module/release/view/create.html.php index 32d21a049f..6a14e4d930 100644 --- a/module/release/view/create.html.php +++ b/module/release/view/create.html.php @@ -49,6 +49,18 @@ release->desc;?> + + release->notify;?> + release->notifyList);?> + + + release->mailto;?> + +
+ chooseUsersToMail}' multiple");?> +
+ + files;?> fetch('file', 'buildform');?> diff --git a/module/release/view/edit.html.php b/module/release/view/edit.html.php index c47c639e62..8b00e012d1 100644 --- a/module/release/view/edit.html.php +++ b/module/release/view/edit.html.php @@ -52,6 +52,18 @@ release->desc;?> desc), "rows=10 class='form-control kindeditor' hidefocus='true'");?> + + release->notify;?> + release->notifyList, $release->notify);?> + + + release->mailto;?> + +
+ mailto, "class='form-control chosen' data-placeholder='{$lang->chooseUsersToMail}' multiple");?> +
+ + files;?> fetch('file', 'buildform');?> diff --git a/module/release/view/sendmail.html.php b/module/release/view/sendmail.html.php new file mode 100644 index 0000000000..d33dcb10a2 --- /dev/null +++ b/module/release/view/sendmail.html.php @@ -0,0 +1,35 @@ + + * @package release + * @version $Id: sendmail.html.php 867 2021-08-12 13:37:58Z $ + * @link http://www.zentao.net + */ +?> +id . ' ' . $release->name;?> +app->openApp == 'product' ? 'release' : 'projectrelease';?> +app->getModuleRoot() . 'common/view/mail.header.html.php';?> + + + + + + +
+ config->mail, 'domain', common::getSysURL()) . helper::createLink($module, 'view', "releaseID=$release->id", 'html'), $mailTitle, '', "text-decoration: underline;'");?> +
+ + + + +
+ lang->release->desc;?> +
desc;?>
+
+ + +app->getModuleRoot() . 'common/view/mail.footer.html.php';?> diff --git a/xuanxuan/module/message/ext/config/xuanxuan.php b/xuanxuan/module/message/ext/config/xuanxuan.php index 2c118573b6..7e1ba6a874 100644 --- a/xuanxuan/module/message/ext/config/xuanxuan.php +++ b/xuanxuan/module/message/ext/config/xuanxuan.php @@ -1,6 +1,7 @@ message->available['xuanxuan']['story'] = $config->message->objectTypes['story']; -$config->message->available['xuanxuan']['task'] = $config->message->objectTypes['task']; -$config->message->available['xuanxuan']['bug'] = $config->message->objectTypes['bug']; -$config->message->available['xuanxuan']['todo'] = $config->message->objectTypes['todo']; -$config->message->setting['xuanxuan']['setting'] = $config->message->available['xuanxuan']; +$config->message->available['xuanxuan']['story'] = $config->message->objectTypes['story']; +$config->message->available['xuanxuan']['task'] = $config->message->objectTypes['task']; +$config->message->available['xuanxuan']['bug'] = $config->message->objectTypes['bug']; +$config->message->available['xuanxuan']['todo'] = $config->message->objectTypes['todo']; +$config->message->available['xuanxuan']['release'] = $config->message->objectTypes['release']; +$config->message->setting['xuanxuan']['setting'] = $config->message->available['xuanxuan'];