* finish task #2719,2729.

This commit is contained in:
wangyidong
2016-11-25 15:32:28 +08:00
parent cc1e0f2cf0
commit 7ac6afe616
25 changed files with 420 additions and 424 deletions
+16 -73
View File
@@ -221,7 +221,7 @@ class bug extends control
}
$actionID = $this->action->create('bug', $bugID, 'Opened');
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
$location = $this->createLink('bug', 'browse', "productID={$this->post->product}&branch=$branch&type=byModule&param={$this->post->module}");
$response['locate'] = isset($_SESSION['bugList']) ? $this->session->bugList : $location;
@@ -361,7 +361,7 @@ class bug extends control
if(!empty($_POST))
{
$actions = $this->bug->batchCreate($productID, $branch);
foreach($actions as $bugID => $actionID) $this->sendmail($bugID, $actionID);
foreach($actions as $bugID => $actionID) $this->bug->sendmail($bugID, $actionID);
die(js::locate($this->session->bugList, 'parent'));
}
@@ -502,7 +502,7 @@ class bug extends control
if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ;
$actionID = $this->action->create('bug', $bugID, $action, $fileAction . $this->post->comment);
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
$bug = $this->bug->getById($bugID);
@@ -597,7 +597,7 @@ class bug extends control
$actionID = $this->action->create('bug', $bugID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
$bug = $this->bug->getById($bugID);
if($bug->toTask != 0)
@@ -701,7 +701,7 @@ class bug extends control
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('bug', $bugID, 'Assigned', $this->post->comment, $this->post->assignedTo);
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
@@ -737,7 +737,7 @@ class bug extends control
$this->loadModel('action');
$actionID = $this->action->create('bug', $bugID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
}
die(js::locate($this->session->bugList, 'parent'));
@@ -763,7 +763,7 @@ class bug extends control
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('bug', $bugID, 'Assigned', $this->post->comment, $this->post->assignedTo);
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
}
if($type == 'product') die(js::locate($this->createLink('bug', 'browse', "productID=$projectID")));
@@ -785,7 +785,7 @@ class bug extends control
$this->bug->confirm($bugID);
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('bug', $bugID, 'bugConfirmed', $this->post->comment);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
}
@@ -818,7 +818,7 @@ class bug extends control
foreach($bugIDList as $bugID)
{
$actionID = $this->action->create('bug', $bugID, 'bugConfirmed');
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
die(js::locate($this->session->bugList, 'parent'));
}
@@ -840,7 +840,7 @@ class bug extends control
$fileAction = !empty($files) ? $this->lang->addFiles . join(',', $files) . "\n" : '';
$actionID = $this->action->create('bug', $bugID, 'Resolved', $fileAction . $this->post->comment, $this->post->resolution . ($this->post->duplicateBug ? ':' . (int)$this->post->duplicateBug : ''));
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
$bug = $this->bug->getById($bugID);
if($bug->toTask != 0)
@@ -896,7 +896,7 @@ class bug extends control
foreach($bugIDList as $bugID)
{
$actionID = $this->action->create('bug', $bugID, 'Resolved', '', $resolution);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
die(js::locate($this->session->bugList, 'parent'));
}
@@ -916,7 +916,7 @@ class bug extends control
if(dao::isError()) die(js::error(dao::getError()));
$files = $this->loadModel('file')->saveUpload('bug', $bugID);
$actionID = $this->action->create('bug', $bugID, 'Activated', $this->post->comment);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
}
@@ -951,7 +951,7 @@ class bug extends control
$this->bug->close($bugID);
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('bug', $bugID, 'Closed', $this->post->comment);
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
if(isonlybody()) die(js::closeModal('parent.parent'));
die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent'));
}
@@ -1083,7 +1083,7 @@ class bug extends control
$this->bug->close($bugID);
$actionID = $this->action->create('bug', $bugID, 'Closed');
$this->sendmail($bugID, $actionID);
$this->bug->sendmail($bugID, $actionID);
}
if(isset($skipBugs)) echo js::alert(sprintf($this->lang->bug->skipClose, join(',', $skipBugs)));
@@ -1263,64 +1263,6 @@ class bug extends control
$this->display();
}
/**
* Send email.
*
* @param int $bugID
* @param int $actionID
* @access public
* @return void
*/
public function sendmail($bugID, $actionID)
{
/* Reset $this->output. */
$this->clear();
/* Set toList and ccList. */
$bug = $this->bug->getByID($bugID);
$productName = $this->products[$bug->product];
$toList = $bug->assignedTo;
$ccList = trim($bug->mailto, ',');
if($toList == '')
{
if($ccList == '') return;
if(strpos($ccList, ',') === false)
{
$toList = $ccList;
$ccList = '';
}
else
{
$commaPos = strpos($ccList, ',');
$toList = substr($ccList, 0, $commaPos);
$ccList = substr($ccList, $commaPos + 1);
}
}
elseif(strtolower($toList) == 'closed')
{
$toList = $bug->resolvedBy;
}
/* Get action info. */
$actions = $this->action->getList('bug', $bugID);
$action = zget($actions, $actionID, null);
$history = $this->action->getHistory($actionID);
$action->history = isset($history[$actionID]) ? $history[$actionID] : array();
if(strtolower($action->action) == 'opened') $action->comment = $bug->steps;
/* Create the mail content. */
if($action->action == 'opened') $action->comment = '';
$this->view->bug = $bug;
$this->view->action = $action;
$this->view->users = $this->user->getPairs('noletter');
$mailContent = $this->parse($this->moduleName, 'sendmail');
/* Send it. */
$this->loadModel('mail')->send($toList, 'BUG #'. $bug->id . ' ' . $bug->title . ' - ' . $productName, $mailContent, $ccList);
if($this->mail->isError()) trigger_error(join("\n", $this->mail->getError()));
}
/**
* Get data to export
*
@@ -1333,6 +1275,7 @@ class bug extends control
{
if($_POST)
{
$this->loadModel('file');
$bugLang = $this->lang->bug;
$bugConfig = $this->config->bug;
@@ -1469,7 +1412,7 @@ class bug extends control
{
foreach($relatedFiles[$bug->id] as $file)
{
$fileURL = 'http://' . $this->server->http_host . $this->config->webRoot . "data/upload/{$this->app->company->id}/" . $file->pathname;
$fileURL = common::getSysURL() . $this->file->webPath . $file->pathname;
$bug->files .= html::a($fileURL, $file->title, '_blank') . '<br />';
}
}