* finish task #3429.
This commit is contained in:
@@ -766,6 +766,34 @@ class bug extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch change branch.
|
||||
*
|
||||
* @param int $branchID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function batchChangeBranch($branchID)
|
||||
{
|
||||
if($this->post->bugIDList)
|
||||
{
|
||||
$bugIDList = $this->post->bugIDList;
|
||||
$bugIDList = array_unique($bugIDList);
|
||||
unset($_POST['bugIDList']);
|
||||
$allChanges = $this->bug->batchChangeBranch($bugIDList, $branchID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
foreach($allChanges as $bugID => $changes)
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$actionID = $this->action->create('bug', $bugID, 'Edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
$this->bug->sendmail($bugID, $actionID);
|
||||
}
|
||||
}
|
||||
$this->loadModel('score')->create('ajax', 'batchOther');
|
||||
die(js::locate($this->session->bugList, 'parent'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch change the module of bug.
|
||||
*
|
||||
|
||||
@@ -869,6 +869,35 @@ class bugModel extends model
|
||||
$this->linkBugToBuild($bugID, $bug->resolvedBuild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch change branch.
|
||||
*
|
||||
* @param array $bugIDList
|
||||
* @param int $branchID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function batchChangeBranch($bugIDList, $branchID)
|
||||
{
|
||||
$now = helper::now();
|
||||
$allChanges = array();
|
||||
$oldBugs = $this->getByList($bugIDList);
|
||||
foreach($bugIDList as $bugID)
|
||||
{
|
||||
$oldBug = $oldBugs[$bugID];
|
||||
if($branchID == $oldBug->branch) continue;
|
||||
|
||||
$bug = new stdclass();
|
||||
$bug->lastEditedBy = $this->app->user->account;
|
||||
$bug->lastEditedDate = $now;
|
||||
$bug->branch = $branchID;
|
||||
|
||||
$this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->where('id')->eq((int)$bugID)->exec();
|
||||
if(!dao::isError()) $allChanges[$bugID] = common::createChanges($oldBug, $bug);
|
||||
}
|
||||
return $allChanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch change the module of bug.
|
||||
*
|
||||
|
||||
@@ -237,6 +237,23 @@ $currentBrowseType = isset($lang->bug->mySelects[$browseType]) && in_array($brow
|
||||
$misc = common::hasPriv('bug', 'batchActivate') ? "onclick=\"setFormAction('$actionLink')\"" : $class;
|
||||
if($misc) echo "<li>" . html::a('javascript:;', $lang->bug->activate, '', $misc) . "</li>";
|
||||
|
||||
if(common::hasPriv('bug', 'batchChangeBranch') and $this->session->currentProductType != 'normal')
|
||||
{
|
||||
$withSearch = count($branches) > 8;
|
||||
echo "<li class='dropdown-submenu'>";
|
||||
echo html::a('javascript:;', $lang->product->branchName[$this->session->currentProductType], '', "id='branchItem'");
|
||||
echo "<div class='dropdown-menu" . ($withSearch ? ' with-search':'') . "'>";
|
||||
echo "<ul class='dropdown-list'>";
|
||||
foreach($branches as $branchID => $branchName)
|
||||
{
|
||||
$actionLink = $this->createLink('bug', 'batchChangeBranch', "branchID=$branchID");
|
||||
echo "<li class='option' data-key='$branchID'>" . html::a('#', $branchName, '', "onclick=\"setFormAction('$actionLink', 'hiddenwin')\"") . "</li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
if($withSearch) echo "<div class='menu-search'><div class='input-group input-group-sm'><input type='text' class='form-control' placeholder=''><span class='input-group-addon'><i class='icon-search'></i></span></div></div>";
|
||||
echo '</div></li>';
|
||||
}
|
||||
|
||||
if(common::hasPriv('bug', 'batchChangeModule'))
|
||||
{
|
||||
$withSearch = count($modules) > 8;
|
||||
|
||||
@@ -842,6 +842,33 @@ class testcase extends control
|
||||
die(js::locate($this->session->caseList));
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch change branch.
|
||||
*
|
||||
* @param int $branchID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function batchChangeBranch($branchID)
|
||||
{
|
||||
if($this->post->caseIDList)
|
||||
{
|
||||
$caseIDList = $this->post->caseIDList;
|
||||
$caseIDList = array_unique($caseIDList);
|
||||
unset($_POST['caseIDList']);
|
||||
$allChanges = $this->testcase->batchChangeBranch($caseIDList, $branchID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
foreach($allChanges as $caseID => $changes)
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$actionID = $this->action->create('case', $caseID, 'Edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
}
|
||||
|
||||
die(js::locate($this->session->caseList, 'parent'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch change the module of case.
|
||||
*
|
||||
|
||||
@@ -817,6 +817,36 @@ class testcaseModel extends model
|
||||
return $allChanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch change branch.
|
||||
*
|
||||
* @param array $caseIDList
|
||||
* @param int $branchID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function batchChangeBranch($caseIDList, $branchID)
|
||||
{
|
||||
$now = helper::now();
|
||||
$allChanges = array();
|
||||
$oldCases = $this->getByList($caseIDList);
|
||||
foreach($caseIDList as $caseID)
|
||||
{
|
||||
$oldCase = $oldCases[$caseID];
|
||||
if($branchID == $oldCase->branch) continue;
|
||||
|
||||
$case = new stdclass();
|
||||
$case->lastEditedBy = $this->app->user->account;
|
||||
$case->lastEditedDate = $now;
|
||||
$case->branch = $branchID;
|
||||
|
||||
$this->dao->update(TABLE_CASE)->data($case)->autoCheck()->where('id')->eq((int)$caseID)->exec();
|
||||
if(!dao::isError()) $allChanges[$caseID] = common::createChanges($oldCase, $case);
|
||||
}
|
||||
|
||||
return $allChanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch change the module of case.
|
||||
*
|
||||
|
||||
@@ -128,6 +128,23 @@ js::set('branch', $branch);
|
||||
$misc = common::hasPriv('testtask', 'batchRun') ? "onclick=\"setFormAction('$actionLink')\"" : $class;
|
||||
echo "<li>" . html::a('#', $lang->testtask->runCase, '', $misc) . "</li>";
|
||||
|
||||
if(common::hasPriv('testcase', 'batchChangeBranch') and $this->session->currentProductType != 'normal')
|
||||
{
|
||||
$withSearch = count($branches) > 8;
|
||||
echo "<li class='dropdown-submenu'>";
|
||||
echo html::a('javascript:;', $lang->product->branchName[$this->session->currentProductType], '', "id='branchItem'");
|
||||
echo "<div class='dropdown-menu" . ($withSearch ? ' with-search':'') . "'>";
|
||||
echo "<ul class='dropdown-list'>";
|
||||
foreach($branches as $branchID => $branchName)
|
||||
{
|
||||
$actionLink = $this->createLink('testcase', 'batchChangeBranch', "branchID=$branchID");
|
||||
echo "<li class='option' data-key='$branchID'>" . html::a('#', $branchName, '', "onclick=\"setFormAction('$actionLink', 'hiddenwin')\"") . "</li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
if($withSearch) echo "<div class='menu-search'><div class='input-group input-group-sm'><input type='text' class='form-control' placeholder=''><span class='input-group-addon'><i class='icon-search'></i></span></div></div>";
|
||||
echo '</div></li>';
|
||||
}
|
||||
|
||||
if(common::hasPriv('testcase', 'batchChangeModule'))
|
||||
{
|
||||
$withSearch = count($modules) > 8;
|
||||
|
||||
Reference in New Issue
Block a user