* finish task#806.

This commit is contained in:
chencongzhi520@gmail.com
2012-05-30 07:55:15 +00:00
parent 4de23033ef
commit 5816f00af7
10 changed files with 356 additions and 121 deletions
+73
View File
@@ -457,6 +457,79 @@ class bug extends control
$this->display();
}
/**
* Batch edit bug.
*
* @param string $from example:bugBrowse, bugBatchEdit.
* @param int $productID
* @param string $orderBy
* @access public
* @return void
*/
public function batchEdit($from = '', $productID = 0, $orderBy = '')
{
if($from == 'bugBrowse')
{
/* Initialize vars.*/
if(!$orderBy) $orderBy = $this->cookie->qaBugOrder ? $this->cookie->qaBugOrder : 'id_desc';
$editedBugs = array();
$allBugs = $this->dao->select('*')->from(TABLE_BUG)->alias('t1')->where($this->session->bugReportCondition)->orderBy($orderBy)->fetchAll('id');
$bugIDList = $this->post->bugIDList ? $this->post->bugIDList : array();
$product = $this->product->getByID($productID);
$columns = 9;
$showSuhosinInfo = false;
/* Set product menu. */
$this->bug->setMenu($this->products, $productID);
/* Initialize the tasks whose need to edited. */
foreach($allBugs as $bug) if(in_array($bug->id, $bugIDList)) $editedBugs[$bug->id] = $bug;
/* Judge whether the editedTasks is too large. */
$showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($editedBugs), $columns);
/* Set the sessions. */
$this->app->session->set('showSuhosinInfo', $showSuhosinInfo);
/* Assign. */
$this->view->header['title'] = $product->name . $this->lang->colon . $this->lang->bug->batchEdit;
$this->view->position[] = $this->lang->bug->batchEdit;
if($showSuhosinInfo) $this->view->suhosinInfo = $this->lang->suhosinInfo;
$this->view->productID = $productID;
$this->view->editedBugs = $editedBugs;
$this->view->users = $this->user->getPairs('noletter');
$this->display();
}
elseif($from == 'bugBatchEdit')
{
$allChanges = $this->bug->batchUpdate();
foreach($allChanges as $bugID => $changes)
{
$actionID = $this->action->create('bug', $bugID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendmail($bugID, $actionID);
$bug = $this->bug->getById($bugID);
if($bug->toTask != 0)
{
foreach($changes as $change)
{
if($change['field'] == 'status')
{
$confirmURL = $this->createLink('task', 'view', "taskID=$bug->toTask");
$cancelURL = $this->server->HTTP_REFERER;
die(js::confirm(sprintf($this->lang->bug->remindTask, $bug->task), $confirmURL, $cancelURL, 'parent', 'parent'));
}
}
}
}
die(js::locate($this->session->bugList));
}
}
/**
* confirm a bug.
*