* Finish task #44368.
This commit is contained in:
+33
-23
@@ -266,41 +266,46 @@ class mailModel extends model
|
||||
* @param string $body
|
||||
* @param array $ccList
|
||||
* @param bool $includeMe
|
||||
* @param array $emails
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function send($toList, $subject, $body = '', $ccList = '', $includeMe = false)
|
||||
public function send($toList, $subject, $body = '', $ccList = '', $includeMe = false, $emails = array())
|
||||
{
|
||||
if(!$this->config->mail->turnon) return;
|
||||
if(!empty($this->config->mail->async)) return $this->addQueue($toList, $subject, $body, $ccList, $includeMe);
|
||||
|
||||
ob_start();
|
||||
$toList = $toList ? explode(',', str_replace(' ', '', $toList)) : array();
|
||||
$ccList = $ccList ? explode(',', str_replace(' ', '', $ccList)) : array();
|
||||
|
||||
/* Process toList and ccList, remove current user from them. If toList is empty, use the first cc as to. */
|
||||
if($includeMe == false)
|
||||
if(empty($emails))
|
||||
{
|
||||
$account = isset($this->app->user->account) ? $this->app->user->account : '';
|
||||
$toList = $toList ? explode(',', str_replace(' ', '', $toList)) : array();
|
||||
$ccList = $ccList ? explode(',', str_replace(' ', '', $ccList)) : array();
|
||||
|
||||
foreach($toList as $key => $to) if(trim($to) == $account or !trim($to)) unset($toList[$key]);
|
||||
foreach($ccList as $key => $cc) if(trim($cc) == $account or !trim($cc)) unset($ccList[$key]);
|
||||
/* Process toList and ccList, remove current user from them. If toList is empty, use the first cc as to. */
|
||||
if($includeMe == false)
|
||||
{
|
||||
$account = isset($this->app->user->account) ? $this->app->user->account : '';
|
||||
|
||||
foreach($toList as $key => $to) if(trim($to) == $account or !trim($to)) unset($toList[$key]);
|
||||
foreach($ccList as $key => $cc) if(trim($cc) == $account or !trim($cc)) unset($ccList[$key]);
|
||||
}
|
||||
|
||||
/* Remove deleted users. */
|
||||
$users = $this->loadModel('user')->getPairs('nodeleted|all');
|
||||
foreach($toList as $key => $to) if(!isset($users[trim($to)])) unset($toList[$key]);
|
||||
foreach($ccList as $key => $cc) if(!isset($users[trim($cc)])) unset($ccList[$key]);
|
||||
|
||||
if(!$toList and !$ccList) return;
|
||||
if(!$toList and $ccList) $toList = array(array_shift($ccList));
|
||||
$toList = join(',', $toList);
|
||||
$ccList = join(',', $ccList);
|
||||
|
||||
/* Get realname and email of users. */
|
||||
$this->loadModel('user');
|
||||
$emails = $this->user->getRealNameAndEmails(str_replace(' ', '', $toList . ',' . $ccList));
|
||||
}
|
||||
|
||||
/* Remove deleted users. */
|
||||
$users = $this->loadModel('user')->getPairs('nodeleted|all');
|
||||
foreach($toList as $key => $to) if(!isset($users[trim($to)])) unset($toList[$key]);
|
||||
foreach($ccList as $key => $cc) if(!isset($users[trim($cc)])) unset($ccList[$key]);
|
||||
|
||||
if(!$toList and !$ccList) return;
|
||||
if(!$toList and $ccList) $toList = array(array_shift($ccList));
|
||||
$toList = join(',', $toList);
|
||||
$ccList = join(',', $ccList);
|
||||
|
||||
/* Get realname and email of users. */
|
||||
$this->loadModel('user');
|
||||
$emails = $this->user->getRealNameAndEmails(str_replace(' ', '', $toList . ',' . $ccList));
|
||||
|
||||
$this->clear();
|
||||
|
||||
/* Replace full webPath image for mail. */
|
||||
@@ -741,7 +746,12 @@ class mailModel extends model
|
||||
}
|
||||
else
|
||||
{
|
||||
$sendUsers = $this->{$objectType}->getToAndCcList($object);
|
||||
$sendUsers = $this->{$objectType}->getToAndCcList($object);
|
||||
}
|
||||
|
||||
if($objectType == 'release' and strpos(",{$object->notify},", ',FB,') !== false)
|
||||
{
|
||||
$this->release->sendMail2Feedback($object, $subject);
|
||||
}
|
||||
|
||||
if(!$sendUsers) return;
|
||||
|
||||
@@ -58,6 +58,9 @@ $lang->release->yesterday = 'Released Yesterday';
|
||||
$lang->release->all = 'All';
|
||||
$lang->release->notify = 'Notify';
|
||||
$lang->release->mailto = 'Mailto';
|
||||
$lang->release->mailContent = '<p>Dear users,</p><p style="margin-left: 30px;">The following requirements and bugs you feedback have been released in the %s. Please contact your account manager to check the latest version.</p>';
|
||||
$lang->release->storyList = '<p style="margin-left: 30px;">Story List:%s。</p>';
|
||||
$lang->release->bugList = '<p style="margin-left: 30px;">Bug List:%s。</p>';
|
||||
|
||||
$lang->release->filePath = 'Download : ';
|
||||
$lang->release->scmPath = 'SCM Path : ';
|
||||
@@ -77,6 +80,7 @@ $lang->release->changeStatusList['terminate'] = 'Terminated';
|
||||
$lang->release->action = new stdclass();
|
||||
$lang->release->action->changestatus = array('main' => '$date, $extra by <strong>$actor</strong>', 'extra' => 'changeStatusList');
|
||||
|
||||
$lang->release->notifyList['FB'] = "Feedback By";
|
||||
$lang->release->notifyList['PO'] = "{$lang->productCommon} Owner";
|
||||
$lang->release->notifyList['QD'] = 'QA Manager';
|
||||
$lang->release->notifyList['SC'] = 'Story Creator';
|
||||
|
||||
@@ -58,6 +58,9 @@ $lang->release->yesterday = '昨日发布';
|
||||
$lang->release->all = '所有';
|
||||
$lang->release->notify = '通知人员';
|
||||
$lang->release->mailto = '抄送给';
|
||||
$lang->release->mailContent = '<p>尊敬的用户,您好!</p><p style="margin-left: 30px;">您反馈的如下需求和Bug已经在 %s版本中发布,请联系客户经理查看最新版本。</p>';
|
||||
$lang->release->storyList = '<p style="margin-left: 30px;">需求列表:%s。</p>';
|
||||
$lang->release->bugList = '<p style="margin-left: 30px;">Bug列表:%s。</p>';
|
||||
|
||||
$lang->release->filePath = '下载地址:';
|
||||
$lang->release->scmPath = '版本库地址:';
|
||||
@@ -77,6 +80,7 @@ $lang->release->changeStatusList['terminate'] = '停止维护';
|
||||
$lang->release->action = new stdclass();
|
||||
$lang->release->action->changestatus = array('main' => '$date, 由 <strong>$actor</strong> $extra。', 'extra' => 'changeStatusList');
|
||||
|
||||
$lang->release->notifyList['FB'] = "反馈者";
|
||||
$lang->release->notifyList['PO'] = "{$lang->productCommon}负责人";
|
||||
$lang->release->notifyList['QD'] = '测试负责人';
|
||||
$lang->release->notifyList['SC'] = '需求提交人';
|
||||
|
||||
@@ -519,4 +519,82 @@ class releaseModel extends model
|
||||
|
||||
return array($toList, $ccList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mail to feedback user.
|
||||
*
|
||||
* @param object $release
|
||||
* @param string $subject
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function sendMail2Feedback($release, $subject)
|
||||
{
|
||||
$stories = $bugs = array();
|
||||
|
||||
$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($buildObjects->stories, ',')) + explode(',', trim($releaseObjects->stories, ','));
|
||||
$bugs = explode(',', trim($buildObjects->bugs, ',')) + explode(',', trim($releaseObjects->bugs, ','));
|
||||
|
||||
if(!empty($stories))
|
||||
{
|
||||
$storyNotifyList = $this->dao->select('id,title,notifyEmail')->from(TABLE_STORY)
|
||||
->where('id')->in($stories)
|
||||
->andWhere('notifyEmail')->ne('')
|
||||
->fetchGroup('notifyEmail', 'id');
|
||||
|
||||
$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 $storyList)
|
||||
{
|
||||
$email = new stdClass();
|
||||
foreach($storyList as $story)
|
||||
{
|
||||
$storyNames[] = $story->title;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,12 @@ $(function()
|
||||
if($.inArray(source, feedbackSource) != -1)
|
||||
{
|
||||
$('#feedbackBox').removeClass('hidden');
|
||||
$('#reviewerBox').attr('colspan', 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#feedbackBox').addClass('hidden');
|
||||
$('#reviewerBox').attr('colspan', 4);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -183,11 +183,11 @@
|
||||
<th><?php echo $lang->story->estimate;?></th>
|
||||
<td><?php echo $story->parent >= 0 ? html::input('estimate', $story->estimate, "class='form-control'") : $story->estimate;?></td>
|
||||
</tr>
|
||||
<tr class='feedbackBox <?php echo strpos(',customre,support,', $story->source) !== false ? '' : 'hidden';?>'>
|
||||
<tr class='feedbackBox <?php echo in_array($story->source, $config->story->feedbackSource) ? '' : 'hidden';?>'>
|
||||
<th><?php echo $lang->story->feedbackBy;?></th>
|
||||
<td><?php echo html::input('feedbackBy', $story->feedbackBy, "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr class='feedbackBox <?php echo strpos(',customre,support,', $story->source) !== false ? '' : 'hidden';?>'>
|
||||
<tr class='feedbackBox <?php echo in_array($story->source, $config->story->feedbackSource) ? '' : 'hidden';?>'>
|
||||
<th><?php echo $lang->story->notifyEmail;?></th>
|
||||
<td><?php echo html::input('notifyEmail', $story->notifyEmail, "class='form-control'");?></td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user