diff --git a/module/execution/control.php b/module/execution/control.php index f972d8278f..8994afccf6 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1452,7 +1452,7 @@ class execution extends control $this->view->users = $this->loadModel('user')->getPairs('nodeleted|noclosed'); $this->view->copyExecution = isset($copyExecution) ? $copyExecution : ''; $this->view->from = $this->app->tab; - $this->view->isStage = $isStage; + $this->view->isStage = (isset($project->model) and $project->model == 'waterfall') ? true : false; $this->display(); } diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index 3633867253..0dcf165106 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -360,6 +360,7 @@ if($config->systemMode == 'new') $lang->resource->projectrelease->unlinkBug = 'unlinkBug'; $lang->resource->projectrelease->batchUnlinkBug = 'batchUnlinkBug'; $lang->resource->projectrelease->changeStatus = 'changeStatus'; + $lang->resource->projectrelease->notify = 'notify'; $lang->projectrelease->methodOrder[5] = 'browse'; $lang->projectrelease->methodOrder[10] = 'create'; @@ -374,6 +375,7 @@ if($config->systemMode == 'new') $lang->projectrelease->methodOrder[60] = 'unlinkBug'; $lang->projectrelease->methodOrder[65] = 'batchUnlinkBug'; $lang->projectrelease->methodOrder[70] = 'changeStatus'; + $lang->projectrelease->methodOrder[75] = 'notify'; /* Stage. */ $lang->resource->stage = new stdclass(); @@ -599,6 +601,7 @@ $lang->resource->release->linkBug = 'linkBug'; $lang->resource->release->unlinkBug = 'unlinkBug'; $lang->resource->release->batchUnlinkBug = 'batchUnlinkBug'; $lang->resource->release->changeStatus = 'changeStatus'; +$lang->resource->release->notify = 'notify'; $lang->release->methodOrder[5] = 'browse'; $lang->release->methodOrder[10] = 'create'; @@ -613,6 +616,7 @@ $lang->release->methodOrder[55] = 'linkBug'; $lang->release->methodOrder[60] = 'unlinkBug'; $lang->release->methodOrder[65] = 'batchUnlinkBug'; $lang->release->methodOrder[70] = 'changeStatus'; +$lang->release->methodOrder[75] = 'notify'; /* Kanban */ $lang->resource->kanban = new stdclass(); diff --git a/module/message/config.php b/module/message/config.php index 8a43c85f6b..d39fb726e9 100644 --- a/module/message/config.php +++ b/module/message/config.php @@ -10,8 +10,6 @@ $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->objectTypes['mr'] = array('compilepass', 'compilefail'); $config->message->available = array(); $config->message->available['mail']['story'] = $config->message->objectTypes['story']; @@ -19,8 +17,6 @@ $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['mail']['mr'] = $config->message->objectTypes['mr']; $config->message->available['webhook'] = $config->message->objectTypes; @@ -30,8 +26,6 @@ $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->available['message']['mr'] = $config->message->objectTypes['mr']; $config->message->typeLink = array(); $config->message->typeLink['mail'] = 'mail|index'; diff --git a/module/projectrelease/control.php b/module/projectrelease/control.php index e6554f8cbb..a3e63f1bf6 100644 --- a/module/projectrelease/control.php +++ b/module/projectrelease/control.php @@ -277,6 +277,34 @@ class projectrelease extends control $this->display(); } + /** + * Notify for release. + * + * @param int $releaseID + * @access public + * @return void + */ + public function notify($releaseID) + { + if($_POST) + { + if(isset($_POST['notify'])) + { + $notify = implode(',', $this->post->notify); + $this->dao->update(TABLE_RELEASE)->set('notify')->eq($notify)->where('id')->eq($releaseID)->exec(); + + $this->release->sendmail($releaseID); + } + + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); + } + + $this->view->release = $this->release->getById($releaseID); + $this->view->actions = $this->loadModel('action')->getList('release', $releaseID); + $this->view->users = $this->loadModel('user')->getPairs('noletter|noclosed'); + $this->display(); + } + /** * Delete a release. * diff --git a/module/projectrelease/model.php b/module/projectrelease/model.php index 2ff48bdd3a..0fa9fe0c22 100644 --- a/module/projectrelease/model.php +++ b/module/projectrelease/model.php @@ -130,7 +130,6 @@ class projectreleaseModel extends model ->join('stories', ',') ->join('bugs', ',') ->join('mailto', ',') - ->join('notify', ',') ->setIF($this->post->build == false, 'build', $buildID) ->setIF($productID, 'product', $productID) ->setIF($branch, 'branch', $branch) @@ -226,7 +225,6 @@ class projectreleaseModel extends model $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') @@ -324,4 +322,21 @@ class projectreleaseModel extends model $this->loadModel('action'); foreach($this->post->bugs as $bugID) $this->action->create('bug', $bugID, 'linked2release', '', $releaseID); } + + /** + * Judge btn is clickable or not. + * + * @param int $release + * @param string $action + * @static + * @access public + * @return bool + */ + public static function isClickable($release, $action) + { + $action = strtolower($action); + + if($action == 'notify') return $release->bugs or $release->stories; + return true; + } } diff --git a/module/projectrelease/view/browse.html.php b/module/projectrelease/view/browse.html.php index 063d29fdb3..c6c01a9eb3 100644 --- a/module/projectrelease/view/browse.html.php +++ b/module/projectrelease/view/browse.html.php @@ -50,7 +50,7 @@ $extendFields = $this->projectrelease->getFlowExtendFields(); foreach($extendFields as $extendField) echo "{$extendField->name}"; ?> - actions;?> + actions;?> @@ -84,7 +84,8 @@ $changedStatus = $release->status == 'normal' ? 'terminate' : 'normal'; echo html::a($this->createLink('projectrelease', 'changeStatus', "releaseID=$release->id&status=$changedStatus"), ' ', 'hiddenwin', "class='btn' title='{$lang->release->changeStatusList[$changedStatus]}'"); } - common::printIcon('projectrelease', 'edit', "release=$release->id", $release, 'list'); + common::printIcon('projectrelease', 'edit', "release=$release->id", $release, 'list'); + common::printIcon('projectrelease', 'notify', "release=$release->id", $release, 'list', 'bullhorn', '', 'iframe', true); if(common::hasPriv('projectrelease', 'delete', $release)) { $deleteURL = $this->createLink('projectrelease', 'delete', "releaseID=$release->id&confirm=yes"); diff --git a/module/projectrelease/view/create.html.php b/module/projectrelease/view/create.html.php index 254435a174..4973cb1f44 100644 --- a/module/projectrelease/view/create.html.php +++ b/module/projectrelease/view/create.html.php @@ -59,10 +59,6 @@ release->desc;?> - - release->notify;?> - release->notifyList);?> - release->mailto;?> diff --git a/module/projectrelease/view/edit.html.php b/module/projectrelease/view/edit.html.php index 60e7796607..5487ac56fc 100644 --- a/module/projectrelease/view/edit.html.php +++ b/module/projectrelease/view/edit.html.php @@ -52,10 +52,6 @@ release->desc;?> desc), "rows=10 class='form-control kindeditor' hidefocus='true'");?> - - release->notify;?> - release->notifyList, $release->notify);?> - release->mailto;?> diff --git a/module/projectrelease/view/notify.html.php b/module/projectrelease/view/notify.html.php new file mode 100644 index 0000000000..58c4b23017 --- /dev/null +++ b/module/projectrelease/view/notify.html.php @@ -0,0 +1,39 @@ + + * @package bug + * @version $Id: notify.html.php 4129 2021-12-01 01:58:14Z wwccss $ + * @link http://www.zentao.net + */ +?> + + +
+
+
+

+ id;?> + name . ' - ' . $lang->release->notify;?> +

+
+
+ + + + + + id);?> + + + +
release->notifyUsers;?>release->notifyList, 'FB');?>
release->notify);?>
+
+
+
+
+
+ diff --git a/module/release/control.php b/module/release/control.php index 76bce38036..b3ecea2119 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -221,6 +221,34 @@ class release extends control $this->display(); } + /** + * Notify for release. + * + * @param int $releaseID + * @access public + * @return void + */ + public function notify($releaseID) + { + if($_POST) + { + if(isset($_POST['notify'])) + { + $notify = implode(',', $this->post->notify); + $this->dao->update(TABLE_RELEASE)->set('notify')->eq($notify)->where('id')->eq($releaseID)->exec(); + + $this->release->sendmail($releaseID); + } + + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); + } + + $this->view->release = $this->release->getById($releaseID); + $this->view->actions = $this->loadModel('action')->getList('release', $releaseID); + $this->view->users = $this->loadModel('user')->getPairs('noletter|noclosed'); + $this->display(); + } + /** * Delete a release. * diff --git a/module/release/lang/de.php b/module/release/lang/de.php index 031c95cf46..15a777946d 100644 --- a/module/release/lang/de.php +++ b/module/release/lang/de.php @@ -57,6 +57,7 @@ $lang->release->export = 'Export as HTML'; $lang->release->yesterday = 'Gestern veröffentlicht'; $lang->release->all = 'All'; $lang->release->notify = 'Notify'; +$lang->release->notifyUsers = 'Notify Users'; $lang->release->mailto = 'Mailto'; $lang->release->filePath = 'Download : '; diff --git a/module/release/lang/en.php b/module/release/lang/en.php index 957247d949..ff325aa7ac 100644 --- a/module/release/lang/en.php +++ b/module/release/lang/en.php @@ -57,6 +57,7 @@ $lang->release->export = 'Export as HTML'; $lang->release->yesterday = 'Released Yesterday'; $lang->release->all = 'All'; $lang->release->notify = 'Notify'; +$lang->release->notifyUsers = 'Notify Users'; $lang->release->mailto = 'Mailto'; $lang->release->mailContent = '

Dear users,

The following requirements and bugs you feedback have been released in the %s. Please contact your account manager to check the latest version.

'; $lang->release->storyList = '

Story List:%s。

'; diff --git a/module/release/lang/fr.php b/module/release/lang/fr.php index ffc16ca3dc..c0712436e4 100644 --- a/module/release/lang/fr.php +++ b/module/release/lang/fr.php @@ -57,6 +57,7 @@ $lang->release->export = 'Export HTML'; $lang->release->yesterday = 'Versionné Hier'; $lang->release->all = 'Tout'; $lang->release->notify = 'Notify'; +$lang->release->notifyUsers = 'Notify Users'; $lang->release->mailto = 'Mailto'; $lang->release->filePath = 'Télecharger : '; diff --git a/module/release/lang/vi.php b/module/release/lang/vi.php index 8d273a0dac..424ef3b666 100644 --- a/module/release/lang/vi.php +++ b/module/release/lang/vi.php @@ -57,6 +57,7 @@ $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->notifyUsers = 'Notify Users'; $lang->release->mailto = 'Mailto'; $lang->release->filePath = 'Tải về : '; diff --git a/module/release/lang/zh-cn.php b/module/release/lang/zh-cn.php index 616baa0c4d..87ed5304bd 100644 --- a/module/release/lang/zh-cn.php +++ b/module/release/lang/zh-cn.php @@ -56,7 +56,8 @@ $lang->release->createdBugs = '本次共遗留 %s 个Bug'; $lang->release->export = '导出HTML'; $lang->release->yesterday = '昨日发布'; $lang->release->all = '所有'; -$lang->release->notify = '通知人员'; +$lang->release->notify = '通知'; +$lang->release->notifyUsers = '通知人员'; $lang->release->mailto = '抄送给'; $lang->release->mailContent = '

尊敬的用户,您好!

您反馈的如下需求和Bug已经在 %s版本中发布,请联系客户经理查看最新版本。

'; $lang->release->storyList = '

需求列表:%s。

'; diff --git a/module/release/model.php b/module/release/model.php index 19152c8153..e8c4dd0e5d 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -129,7 +129,6 @@ class releaseModel extends model ->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') @@ -228,9 +227,7 @@ class releaseModel extends model $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) - ->setIF(!$this->post->notify, 'notify', '') ->cleanInt('product') ->remove('files,labels,allchecker,uid') ->get(); @@ -478,6 +475,70 @@ class releaseModel extends model return !dao::isError(); } + /** + * Judge btn is clickable or not. + * + * @param int $release + * @param string $action + * @static + * @access public + * @return bool + */ + public static function isClickable($release, $action) + { + $action = strtolower($action); + + if($action == 'notify') return $release->bugs or $release->stories; + return true; + } + + /** + * Send mail to release related users. + * + * @param int $releaseID + * @access public + * @return void + */ + public function sendmail($releaseID) + { + if(empty($releaseID)) return; + $this->app->loadConfig('mail'); + + /* Load module and get vars. */ + $users = $this->loadModel('user')->getPairs('noletter'); + $release = $this->getByID($releaseID); + $suffix = empty($release->product) ? '' : ' - ' . $this->loadModel('product')->getById($release->product)->name; + $subject = 'Release #' . $release->id . ' ' . $release->name . $suffix; + + /* 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); + + if(strpos(",{$release->notify},", ',FB,') !== false) $this->sendMail2Feedback($release, $subject); + + /* Get the sender. */ + $sendUsers = $this->getToAndCcList($release); + if(!$sendUsers) return; + + list($toList, $ccList) = $sendUsers; + + /* Send it. */ + $this->loadModel('mail')->send($toList, $subject, $mailContent, $ccList); + } + /** * Get toList and ccList. * @@ -531,71 +592,58 @@ class releaseModel extends model */ public function sendMail2Feedback($release, $subject) { - $stories = $bugs = array(); + if(!$release->stories && !$release->bugs) return; - $buildObjects = $this->dao->select('stories,bugs')->from(TABLE_BUILD)->where('id')->eq($release->build)->fetch(); - $releaseObjects = $this->dao->select('stories,bugs')->from(TABLE_RELEASE)->where('id')->eq($release->id)->fetch(); + $stories = explode(',', trim($release->stories, ',')); + $bugs = explode(',', trim($release->bugs, ',')); - $stories = explode(',', trim($buildObjects->stories, ',')) + explode(',', trim($releaseObjects->stories, ',')); - $bugs = explode(',', trim($buildObjects->bugs, ',')) + explode(',', trim($releaseObjects->bugs, ',')); + $storyNotifyList = $this->dao->select('id,title,notifyEmail')->from(TABLE_STORY) + ->where('id')->in($stories) + ->andWhere('notifyEmail')->ne('') + ->fetchGroup('notifyEmail', 'id'); - if(!empty($stories)) + $bugNotifyList = $this->dao->select('id,title,notifyEmail')->from(TABLE_BUG) + ->where('id')->in($bugs) + ->andWhere('notifyEmail')->ne('') + ->fetchGroup('notifyEmail', 'id'); + + $toList = array(); + $emails = array(); + $storyNames = array(); + $bugNames = array(); + foreach($storyNotifyList as $notifyEmail => $storyList) { - $storyNotifyList = $this->dao->select('id,title,notifyEmail')->from(TABLE_STORY) - ->where('id')->in($stories) - ->andWhere('notifyEmail')->ne('') - ->fetchGroup('notifyEmail', 'id'); + $email = new stdClass(); + $email->account = $notifyEmail; + $email->email = $notifyEmail; + $email->realname = ''; - $bugNotifyList = $this->dao->select('id,title,notifyEmail')->from(TABLE_BUG) - ->where('id')->in($bugs) - ->andWhere('notifyEmail')->ne('') - ->fetchGroup('notifyEmail', 'id'); + $emails[$notifyEmail] = $email; + $toList[$notifyEmail] = $notifyEmail; - $toList = array(); - $emails = array(); - $storyNames = array(); - $bugNames = array(); - foreach($storyNotifyList as $storyList) - { - $email = new stdClass(); - foreach($storyList as $story) - { - $storyNames[] = $story->title; + foreach($storyList as $story) $storyNames[] = $story->title; + } + foreach($bugNotifyList as $notifyEmail => $bugList) + { + $email = new stdClass(); + $email->account = $notifyEmail; + $email->email = $notifyEmail; + $email->realname = ''; - if(isset($email->account)) continue; - $email->account = $story->notifyEmail; - $email->email = $story->notifyEmail; - $email->realname = ''; - $emails[$story->notifyEmail] = $email; - $toList[$story->notifyEmail] = $story->notifyEmail; - } - } - foreach($bugNotifyList as $bugList) - { - $email = new stdClass(); - foreach($bugList as $bug) - { - $bugNames[] = $bug->title; + $emails[$notifyEmail] = $email; + $toList[$notifyEmail] = $notifyEmail; - if(isset($email->account)) continue; - $email->account = $bug->notifyEmail; - $email->email = $bug->notifyEmail; - $email->realname = ''; - $emails[$bug->notifyEmail] = $email; - $toList[$bug->notifyEmail] = $bug->notifyEmail; - } - } - - if(!empty($toList)) - { - $storyNames = implode(',', $storyNames); - $bugNames = implode(',', $bugNames); - $mailContent = sprintf($this->lang->release->mailContent, $release->name); - if($storyNames) $mailContent .= sprintf($this->lang->release->storyList, $storyNames); - if($bugNames) $mailContent .= sprintf($this->lang->release->bugList, $bugNames); - $this->loadModel('mail')->send(implode(',', $toList), $subject, $mailContent, '', false, $emails); - } + foreach($bugList as $bug) $bugNames[] = $bug->title; } + if(!empty($toList)) + { + $storyNames = implode(',', $storyNames); + $bugNames = implode(',', $bugNames); + $mailContent = sprintf($this->lang->release->mailContent, $release->name); + if($storyNames) $mailContent .= sprintf($this->lang->release->storyList, $storyNames); + if($bugNames) $mailContent .= sprintf($this->lang->release->bugList, $bugNames); + $this->loadModel('mail')->send(implode(',', $toList), $subject, $mailContent, '', false, $emails); + } } } diff --git a/module/release/view/browse.html.php b/module/release/view/browse.html.php index 52018faaf0..f980074b89 100644 --- a/module/release/view/browse.html.php +++ b/module/release/view/browse.html.php @@ -54,7 +54,7 @@ $extendFields = $this->release->getFlowExtendFields(); foreach($extendFields as $extendField) echo "{$extendField->name}"; ?> - actions;?> + actions;?> @@ -91,6 +91,7 @@ echo html::a($this->createLink('release', 'changeStatus', "releaseID=$release->id&status=$changedStatus"), ' ', 'hiddenwin', "class='btn' title='{$lang->release->changeStatusList[$changedStatus]}'"); } common::printIcon('release', 'edit', "release=$release->id", $release, 'list'); + common::printIcon('release', 'notify', "release=$release->id", $release, 'list', 'bullhorn', '', 'iframe', true); if(common::hasPriv('release', 'delete', $release)) { $deleteURL = $this->createLink('release', 'delete', "releaseID=$release->id&confirm=yes"); diff --git a/module/release/view/create.html.php b/module/release/view/create.html.php index 2601dedcec..16d91956ca 100644 --- a/module/release/view/create.html.php +++ b/module/release/view/create.html.php @@ -49,10 +49,6 @@ release->desc;?> - - release->notify;?> - release->notifyList, 'FB');?> - release->mailto;?> diff --git a/module/release/view/edit.html.php b/module/release/view/edit.html.php index fc023286e7..7919355340 100644 --- a/module/release/view/edit.html.php +++ b/module/release/view/edit.html.php @@ -52,10 +52,6 @@ release->desc;?> desc), "rows=10 class='form-control kindeditor' hidefocus='true'");?> - - release->notify;?> - release->notifyList, $release->notify);?> - release->mailto;?> diff --git a/module/release/view/notify.html.php b/module/release/view/notify.html.php new file mode 100644 index 0000000000..58c4b23017 --- /dev/null +++ b/module/release/view/notify.html.php @@ -0,0 +1,39 @@ + + * @package bug + * @version $Id: notify.html.php 4129 2021-12-01 01:58:14Z wwccss $ + * @link http://www.zentao.net + */ +?> + + +
+
+
+

+ id;?> + name . ' - ' . $lang->release->notify;?> +

+
+
+ + + + + + id);?> + + + +
release->notifyUsers;?>release->notifyList, 'FB');?>
release->notify);?>
+
+
+
+
+
+ diff --git a/module/release/view/sendmail.html.php b/module/release/view/sendmail.html.php index 1af4b05e50..73ca450be9 100644 --- a/module/release/view/sendmail.html.php +++ b/module/release/view/sendmail.html.php @@ -10,7 +10,7 @@ * @link http://www.zentao.net */ ?> -id . ' ' . $object->name;?> +id . ' ' . $release->name;?> app->tab == 'product' ? 'release' : 'projectrelease';?> app->getModuleRoot() . 'common/view/mail.header.html.php';?> @@ -18,7 +18,7 @@
- config->mail, 'domain', common::getSysURL()) . helper::createLink($module, 'view', "releaseID=$object->id", 'html'), $mailTitle, '', "text-decoration: underline;'");?> + config->mail, 'domain', common::getSysURL()) . helper::createLink($module, 'view', "releaseID=$release->id", 'html'), $mailTitle, '', "text-decoration: underline;'");?>
@@ -28,7 +28,7 @@
lang->release->desc;?> -
desc;?>
+
desc;?>