diff --git a/module/branch/control.php b/module/branch/control.php index 4e7585fd14..a83e5d950b 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -43,6 +43,7 @@ class branch extends control $this->view->browseType = $browseType; $this->view->orderBy = $orderBy; $this->view->pager = $pager; + $this->view->product = $this->product->getById($productID); $this->display(); } @@ -65,6 +66,7 @@ class branch extends control die(js::reload('parent.parent')); } + $this->view->product = $this->loadModel('product')->getById($productID); $this->display(); } @@ -75,7 +77,7 @@ class branch extends control * @access public * @return void */ - public function edit($branchID) + public function edit($branchID, $productID) { if($_POST) { @@ -86,7 +88,8 @@ class branch extends control die(js::reload('parent.parent')); } - $this->view->branch = $this->branch->getById($branchID, 0, ''); + $this->view->product = $this->loadModel('product')->getById($productID); + $this->view->branch = $this->branch->getById($branchID, 0, ''); $this->display(); } @@ -123,6 +126,7 @@ class branch extends control if(!in_array($branch->id, $branchIDList)) unset($branchList[$branch->id]); } + $this->view->product = $this->product->getById($productID); $this->view->branchList = $branchList; $this->display(); } diff --git a/module/branch/lang/en.php b/module/branch/lang/en.php index 44eb3d7137..81588bcc14 100644 --- a/module/branch/lang/en.php +++ b/module/branch/lang/en.php @@ -10,12 +10,12 @@ $lang->branch->all = 'All '; $lang->branch->main = 'Main'; $lang->branch->edit = 'Edit'; -$lang->branch->editAction = 'Edit Branch'; +$lang->branch->editAction = 'Edit %s'; $lang->branch->activate = 'Activate'; $lang->branch->activateAction = 'Activate Branch'; $lang->branch->close = 'Close'; $lang->branch->closeAction = 'Close Branch'; -$lang->branch->create = 'Create Branch'; +$lang->branch->create = 'Create %s'; $lang->branch->merge = 'Merge'; $lang->branch->batchEdit = 'Batch Edit'; $lang->branch->defaultBranch = 'Default Branch'; @@ -43,7 +43,7 @@ $lang->branch->confirmActivate = 'Do you want to activate this @branch@?'; $lang->branch->existName = '@branch@ name already exists.'; $lang->branch->noData = 'No branches.'; -$lang->branch->mainBranch = 'The default main branch of the product.'; +$lang->branch->mainBranch = 'The default main %s of the product.'; $lang->branch->statusList = array(); $lang->branch->statusList['active'] = 'Active'; diff --git a/module/branch/lang/zh-cn.php b/module/branch/lang/zh-cn.php index c602d25d93..3e8846ae00 100644 --- a/module/branch/lang/zh-cn.php +++ b/module/branch/lang/zh-cn.php @@ -10,12 +10,12 @@ $lang->branch->all = '所有'; $lang->branch->main = '主干'; $lang->branch->edit = '编辑'; -$lang->branch->editAction = '编辑分支'; +$lang->branch->editAction = '编辑%s'; $lang->branch->activate = '激活'; $lang->branch->activateAction = '激活分支'; $lang->branch->close = '关闭'; $lang->branch->closeAction = '关闭分支'; -$lang->branch->create = '新增分支'; +$lang->branch->create = '新增%s'; $lang->branch->merge = '合并'; $lang->branch->batchEdit = '批量编辑'; $lang->branch->defaultBranch = '默认分支'; @@ -24,11 +24,11 @@ $lang->branch->setDefaultAction = '设置默认分支'; $lang->branch->id = 'ID'; $lang->branch->product = '所属产品'; -$lang->branch->name = '分支名称'; +$lang->branch->name = '%s名称'; $lang->branch->status = '状态'; $lang->branch->createdDate = '创建时间'; $lang->branch->closedDate = '关闭时间'; -$lang->branch->desc = '分支描述'; +$lang->branch->desc = '%s描述'; $lang->branch->order = '排序'; $lang->branch->deleted = '已删除'; $lang->branch->closed = '已关闭'; @@ -43,7 +43,7 @@ $lang->branch->confirmActivate = '是否激活该@branch@?'; $lang->branch->existName = '@branch@名称已存在'; $lang->branch->noData = '暂时没有分支。'; -$lang->branch->mainBranch = '产品默认主干分支。'; +$lang->branch->mainBranch = '产品默认主干%s。'; $lang->branch->statusList = array(); $lang->branch->statusList['active'] = '激活'; diff --git a/module/branch/model.php b/module/branch/model.php index dc74dd3f6c..acd03d415e 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -57,6 +57,7 @@ class branchModel extends model if($browseType == 'closed') return $branchList; + $product = $this->loadModel('product')->getById($productID); $defaultBranch = BRANCH_MAIN; foreach($branchList as $branch) $defaultBranch = $branch->default ? $branch->id : $defaultBranch; @@ -69,7 +70,7 @@ class branchModel extends model $mainBranch->status = 'active'; $mainBranch->createdDate = ''; $mainBranch->closedDate = ''; - $mainBranch->desc = $this->lang->branch->mainBranch; + $mainBranch->desc = sprintf($this->lang->branch->mainBranch, $this->lang->product->branchName[$product->type]); $mainBranch->order = 0; return array($mainBranch) + $branchList; diff --git a/module/branch/view/batchedit.html.php b/module/branch/view/batchedit.html.php index c1164f13e4..805cc4619e 100644 --- a/module/branch/view/batchedit.html.php +++ b/module/branch/view/batchedit.html.php @@ -21,8 +21,8 @@ branch->id;?> - branch->name;?> - branch->desc;?> + branch->name, $lang->product->branchName[$product->type]);?> + branch->desc, $lang->product->branchName[$product->type]);?> branch->status;?> branch->defaultBranch;?> @@ -31,7 +31,7 @@ id == BRANCH_MAIN ? 'disabled' : '';?> - id == BRANCH_MAIN ? '' : $branch->id) . html::hidden("IDList[$branch->id]", $branch);?> + id == BRANCH_MAIN ? '' : $branch->id) . html::hidden("IDList[$branch->id]", $branch->id);?> id]", $branch->name, "class='form-control chosen' $disabled");?> id]", $branch->desc, "class='form-control' $disabled");?> id]", $lang->branch->statusList, $branch->status, "class='form-control' chosen $disabled onchange='canSetDefaultBranch(this)'");?> diff --git a/module/branch/view/create.html.php b/module/branch/view/create.html.php index db3a449ecc..899dc015ac 100644 --- a/module/branch/view/create.html.php +++ b/module/branch/view/create.html.php @@ -13,16 +13,16 @@
-

branch->create;?>

+

branch->create, $lang->product->branchName[$product->type]);?>

- + - + diff --git a/module/branch/view/edit.html.php b/module/branch/view/edit.html.php index ce23a1d75d..8bcb450e4e 100644 --- a/module/branch/view/edit.html.php +++ b/module/branch/view/edit.html.php @@ -13,12 +13,12 @@
-

branch->editAction;?>

+

branch->editAction, $lang->product->branchName[$product->type]);?>

branch->name;?>branch->name, $lang->product->branchName[$product->type]);?>
branch->desc;?>branch->desc, $lang->product->branchName[$product->type]);?>
- + @@ -26,7 +26,7 @@ - + diff --git a/module/branch/view/manage.html.php b/module/branch/view/manage.html.php index 3d9f729d15..4f90fae36a 100644 --- a/module/branch/view/manage.html.php +++ b/module/branch/view/manage.html.php @@ -29,7 +29,7 @@
- " . $lang->branch->create, '', "class='btn btn-primary iframe'", true, true);?> + " . sprintf($lang->branch->create, $lang->product->branchName[$product->type]), '', "class='btn btn-primary iframe'", true, true);?>
@@ -37,7 +37,7 @@

branch->noData;?> - createLink('branch', 'create', "productID=$productID", '', true), " " . $lang->branch->create, '', "class='btn btn-info iframe'");?> + createLink('branch', 'create', "productID=$productID", '', true), " " . sprintf($lang->branch->create, $lang->product->branchName[$product->type]), '', "class='btn btn-info iframe'");?>

@@ -54,11 +54,11 @@
- + - + @@ -99,7 +99,7 @@
branch->name;?>branch->name, $lang->product->branchName[$product->type]);?> name, "class='form-control'");?>
branch->statusList, $branch->status, "class='form-control chosen'");?>
branch->desc;?>branch->desc, $lang->product->branchName[$product->type]);?> desc, "class='form-control'");?>
branch->order;?> branch->name);?>branch->name, $lang->product->branchName[$product->type]));?> branch->status);?> branch->createdDate);?> branch->closedDate);?>branch->desc;?>branch->desc, $lang->product->branchName[$product->type]);?> actions;?>
id", $branch, 'list', '', '', "$disabled iframe", true); + common::printIcon('branch', 'edit', "branchID=$branch->id&productID=$productID", $branch, 'list', '', '', "$disabled iframe", true); if($branch->status == 'active') { common::printIcon('branch', 'close', "branchID=$branch->id", $branch, 'list', 'off', 'hiddenwin', $disabled); diff --git a/module/bug/control.php b/module/bug/control.php index 3052e26bef..a48fc1ec09 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -325,7 +325,7 @@ class bug extends control } else { - $this->qa->setMenu($this->products, $productID); + $this->qa->setMenu($this->products, $productID, $branch); } foreach($output as $paramKey => $paramValue) diff --git a/module/execution/model.php b/module/execution/model.php index 54c37ce3e8..7d8f0cdbbd 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -365,8 +365,8 @@ class executionModel extends model $this->dao->insert(TABLE_EXECUTION)->data($sprint) ->autoCheck($skipFields = 'begin,end') ->batchcheck($this->config->execution->create->requiredFields, 'notempty') - ->checkIF(!empty($sprint->name), 'name', 'unique', "`type` in ('sprint','stage') and `parent` = $sprint->parent") - ->checkIF(!empty($sprint->code), 'code', 'unique', "`type` in ('sprint','stage') and `parent` = $sprint->parent") + ->checkIF(!empty($sprint->name), 'name', 'unique', "`type` in ('sprint','stage') and `project` = $sprint->project") + ->checkIF(!empty($sprint->code), 'code', 'unique', "`type` in ('sprint','stage')") ->checkIF($sprint->begin != '', 'begin', 'date') ->checkIF($sprint->end != '', 'end', 'date') ->checkIF($sprint->end != '', 'end', 'ge', $sprint->begin) @@ -519,6 +519,7 @@ class executionModel extends model ->checkIF($execution->begin != '', 'begin', 'date') ->checkIF($execution->end != '', 'end', 'date') ->checkIF($execution->end != '', 'end', 'ge', $execution->begin) + ->checkIF(!empty($execution->name), 'name', 'unique', "id != $executionID and type in ('sprint','stage') and `project` = $execution->project") ->checkIF(!empty($execution->code), 'code', 'unique', "id != $executionID and type in ('sprint','stage')") ->where('id')->eq($executionID) ->limit(1) @@ -544,7 +545,7 @@ class executionModel extends model $changedAccounts[$owner] = $owner; $teamMembers[$ownerField] = $member; } - if($execution->project) $this->addProjectMembers($execution->project, $teamMembers); + if($execution->project) $this->addProjectMembers($execution->project, $teamMembers); $whitelist = explode(',', $execution->whitelist); $this->loadModel('personnel')->updateWhitelist($whitelist, 'sprint', $executionID); @@ -624,10 +625,6 @@ class executionModel extends model if(isset($data->projects)) $executions[$executionID]->project = zget($data->projects, $executionID, 0); if(isset($data->attributes)) $executions[$executionID]->attribute = zget($data->attributes, $executionID, ''); - /* Check unique name for edited executions. */ - if(isset($nameList[$executionName])) dao::$errors['name'][] = 'execution#' . $executionID . sprintf($this->lang->error->unique, $this->lang->execution->name, $executionName); - $nameList[$executionName] = $executionName; - /* Check unique code for edited executions. */ if($projectModel == 'scrum' and empty($executionCode)) { @@ -646,6 +643,7 @@ class executionModel extends model { $oldExecution = $oldExecutions[$executionID]; $team = $this->loadModel('user')->getTeamMemberPairs($executionID, 'execution'); + $projectID = isset($execution->project) ? $execution->project : $oldExecution->project; $this->dao->update(TABLE_EXECUTION)->data($execution) ->autoCheck($skipFields = 'begin,end') @@ -653,7 +651,8 @@ class executionModel extends model ->checkIF($execution->begin != '', 'begin', 'date') ->checkIF($execution->end != '', 'end', 'date') ->checkIF($execution->end != '', 'end', 'gt', $execution->begin) - ->checkIF(!empty($execution->code), 'code', 'unique', "id NOT " . helper::dbIN($data->executionIDList) . " and type in ('sprint','stage')") + ->checkIF(!empty($execution->name), 'name', 'unique', "id != $executionID and type in ('sprint','stage') and `project` = $projectID") + ->checkIF(!empty($execution->code), 'code', 'unique', "id != $executionID and type in ('sprint','stage')") ->where('id')->eq($executionID) ->limit(1) ->exec(); diff --git a/module/product/control.php b/module/product/control.php index 1e53c206c3..f1628fdda8 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -216,7 +216,7 @@ class product extends control $this->app->loadLang('datatable'); $this->lang->datatable->showBranch = sprintf($this->lang->datatable->showBranch, $this->lang->product->branchName[$product->type]); } - + /* Get stories. */ if($this->app->rawModule == 'projectstory') { @@ -992,16 +992,24 @@ class product extends control } $field = $fieldID ? "plans[$fieldID]" : 'plan'; - $output = html::select($field, $plans, $planID, "class='form-control chosen'"); + $output = "
"; + $output .= "
"; + $output .= html::select($field, $plans, $planID, "class='form-control chosen'"); + $output .= "
"; if(count($plans) == 1 and $needCreate) { + $output .= "
"; $output .= "
"; $output .= html::a($this->createLink('productplan', 'create', "productID=$productID&branch=$branch", '', true), "", '', "class='btn btn-icon' data-toggle='modal' data-type='iframe' data-width='95%' title='{$this->lang->productplan->create}'"); $output .= '
'; + $output .= '
'; + $output .= "
"; $output .= "
"; $output .= html::a("javascript:void(0)", "", '', "class='btn btn-icon refresh' data-toggle='tooltip' title='{$this->lang->refresh}' onclick='loadProductPlans($productID)'"); $output .= '
'; + $output .= '
'; } + $output .= "
"; die($output); } diff --git a/module/product/css/browse.css b/module/product/css/browse.css index 6575d2d175..ab03bd0165 100644 --- a/module/product/css/browse.css +++ b/module/product/css/browse.css @@ -35,3 +35,4 @@ a.removeModule:hover {color: red;} #batchUnlinkStoryTip .table tfoot {position: relative; bottom: -30px;} #batchUnlinkStoryTip .table td {border-bottom: 0px;} #batchUnlinkStoryTip .table th:first-child {width: 460px;} +#mainMenu .dropdown-menu>li>a>.icon {top: 4px;} diff --git a/module/product/model.php b/module/product/model.php index f3a729e875..189f12e1fa 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -477,7 +477,8 @@ class productModel extends model if(strpos($storyMethods, "," . $currentMethod . ",") === false) $currentModule = 'product'; if($currentMethod == 'view' or $currentMethod == 'change' or $currentMethod == 'review') $currentMethod = 'browse'; } - if($currentModule == 'testcase' and $currentMethod == 'view') $currentMethod = 'browse'; + if($currentModule == 'testcase' and strpos(',view,edit,', ",$currentMethod,") !== false) $currentMethod = 'browse'; + if($currentModule == 'bug' and $currentMethod == 'edit') $currentMethod = 'browse'; if($currentMethod == 'report') $currentMethod = 'browse'; $currentProductName = $this->lang->product->common; @@ -562,7 +563,7 @@ class productModel extends model $this->dao->insert(TABLE_PRODUCT)->data($product)->autoCheck() ->batchCheck($this->config->product->create->requiredFields, 'notempty') ->checkIF(!empty($product->name), 'name', 'unique', "`program` = $product->program") - ->checkIF(!empty($product->code), 'code', 'unique', "`program` = $product->program") + ->checkIF(!empty($product->code), 'code', 'unique') ->exec(); if(!dao::isError()) @@ -631,8 +632,8 @@ class productModel extends model $product = $this->loadModel('file')->processImgURL($product, $this->config->product->editor->edit['id'], $this->post->uid); $this->dao->update(TABLE_PRODUCT)->data($product)->autoCheck() ->batchCheck($this->config->product->edit->requiredFields, 'notempty') + ->checkIF(!empty($product->name), 'name', 'unique', "id != $productID and `program` = $product->program") ->checkIF(!empty($product->code), 'code', 'unique', "id != $productID") - ->check('name', 'unique', "id != $productID and deleted = '0'") ->where('id')->eq($productID) ->exec(); @@ -661,6 +662,7 @@ class productModel extends model $data = fixer::input('post')->get(); $oldProducts = $this->getByIdList($this->post->productIDList); $nameList = array(); + foreach($data->productIDList as $productID) { $productName = $data->names[$productID]; @@ -677,10 +679,6 @@ class productModel extends model $products[$productID]->status = $data->statuses[$productID]; $products[$productID]->desc = strip_tags($this->post->descs[$productID], $this->config->allowedTags); $products[$productID]->acl = $data->acls[$productID]; - - /* Check unique name for edited products. */ - if(isset($nameList[$productName])) dao::$errors['name'][] = 'product#' . $productID . sprintf($this->lang->error->unique, $this->lang->product->name, $productName); - $nameList[$productName] = $productName; } if(dao::isError()) die(js::error(dao::getError())); @@ -688,12 +686,13 @@ class productModel extends model foreach($products as $productID => $product) { $oldProduct = $oldProducts[$productID]; + $programID = !isset($product->program) ? $oldProduct->program : (empty($product->program) ? 0 : $product->program); $this->dao->update(TABLE_PRODUCT) ->data($product) ->autoCheck() ->batchCheck($this->config->product->edit->requiredFields , 'notempty') - ->check('name', 'unique', "id NOT " . helper::dbIN($data->productIDList) . " and deleted='0'") + ->checkIF(!empty($product->name), 'name', 'unique', "id != $productID and `program` = $programID") ->where('id')->eq($productID) ->exec(); if(dao::isError()) die(js::error('product#' . $productID . dao::getError(true))); diff --git a/module/program/model.php b/module/program/model.php index 46bb357213..8ab2027d4a 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -741,7 +741,7 @@ class programModel extends model ->checkIF($program->begin != '', 'begin', 'date') ->checkIF($program->end != '', 'end', 'date') ->checkIF($program->end != '', 'end', 'gt', $program->begin) - ->check('name', 'unique', "id!=$programID and deleted='0' and `type`='program'") + ->checkIF(!empty($program->name), 'name', 'unique', "id!=$programID and `type`='program' and `parent` = $program->parent") ->where('id')->eq($programID) ->limit(1) ->exec(); diff --git a/module/project/control.php b/module/project/control.php index 1f87498a8a..db939da273 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -511,9 +511,12 @@ class project extends control /* Link the plan stories. */ $newPlans = array(); - foreach($_POST['plans'] as $plans) + if(isset($_POST['plans'])) { - foreach($plans as $planID) $newPlans[$planID] = $planID; + foreach($_POST['plans'] as $plans) + { + foreach($plans as $planID) $newPlans[$planID] = $planID; + } } $diffResult = array_diff($oldPlans, $newPlans); diff --git a/module/project/model.php b/module/project/model.php index 1e4fb2b56d..b667be0876 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -858,7 +858,7 @@ class projectModel extends model ->autoCheck() ->batchcheck($requiredFields, 'notempty') ->checkIF(!empty($project->name), 'name', 'unique', "`type`='project' and `parent` = $project->parent") - ->checkIF(!empty($project->code), 'code', 'unique', "`type`='project' and `parent` = $project->parent") + ->checkIF(!empty($project->code), 'code', 'unique', "`type`='project'") ->checkIF($project->end != '', 'end', 'gt', $project->begin) ->exec(); @@ -1049,8 +1049,8 @@ class projectModel extends model ->checkIF($project->begin != '', 'begin', 'date') ->checkIF($project->end != '', 'end', 'date') ->checkIF($project->end != '', 'end', 'gt', $project->begin) - ->checkIF(!empty($project->code), 'code', 'unique', "id != $projectID and type='project'") - ->check('name', 'unique', "id != $projectID AND type='project' AND deleted='0'") + ->checkIF(!empty($project->name), 'name', 'unique', "id != $projectID and `type` = 'project' and `parent` = $project->parent") + ->checkIF(!empty($project->code), 'code', 'unique', "id != $projectID and `type` = 'project'") ->where('id')->eq($projectID) ->exec(); @@ -1114,10 +1114,6 @@ class projectModel extends model $projects[$projectID]->lastEditedBy = $this->app->user->account; $projects[$projectID]->lastEditedDate = helper::now(); - /* Check unique name for edited projects. */ - if(isset($nameList[$projectName])) dao::$errors['name'][] = 'project#' . $projectID . sprintf($this->lang->error->unique, $this->lang->project->name, $projectName); - $nameList[$projectName] = $projectName; - if($projects[$projectID]->parent) { $parentProject = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($projects[$projectID]->parent)->fetch(); @@ -1137,12 +1133,16 @@ class projectModel extends model foreach($projects as $projectID => $project) { $oldProject = $oldProjects[$projectID]; + $parentID = !isset($project->parent) ? $oldProject->parent : $project->parent; + $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck($skipFields = 'begin,end') ->batchCheck($this->config->project->edit->requiredFields , 'notempty') ->checkIF($project->begin != '', 'begin', 'date') ->checkIF($project->end != '', 'end', 'date') ->checkIF($project->end != '', 'end', 'gt', $project->begin) + ->checkIF(!empty($project->name), 'name', 'unique', "id != $projectID and `type`='project' and `parent` = $parentID") + ->checkIF(!empty($project->code), 'code', 'unique', "id != $projectID and `type`='project'") ->where('id')->eq($projectID) ->exec(); diff --git a/module/story/css/batchedit.css b/module/story/css/batchedit.css index fc90ab0786..9ffd2dddb8 100644 --- a/module/story/css/batchedit.css +++ b/module/story/css/batchedit.css @@ -2,9 +2,11 @@ .c-id {width: 40px;} .c-estimate {width: 50px;} .c-branch, .c-module {width: 120px;} -.c-plan, .c-title {width: 150px;} +.c-title {width: 150px;} +.c-plan {width: 170px;} .c-category {width: 90px;} .c-pri {width: 70px;} .c-source {width: 130px;} .c-note, .c-stage, .c-reason {width: 100px;} .c-keywords {width: 80px;} +#batchEditForm > div > table > tbody > tr > td:nth-child(4) > div > div:nth-child(1) {width: 60%;} diff --git a/module/story/model.php b/module/story/model.php index de18bce4ae..d9054353cf 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2461,10 +2461,6 @@ class storyModel extends model $storyQuery .= " AND `status` NOT IN ('draft', 'closed')"; } } - elseif($branch) - { - if($branch and strpos($storyQuery, '`branch` =') === false) $storyQuery .= " AND `branch` = $branch"; - } elseif(strpos($storyQuery, $allBranch) !== false) { $storyQuery = str_replace($allBranch, '1', $storyQuery); @@ -4017,7 +4013,7 @@ class storyModel extends model } else { - $stories = $this->getProductStories($productID, 0, 0, 'all', 'story', 'id_desc', true, $excludeStories); + $stories = $this->getProductStories($productID, $branch, 0, 'all', 'story', 'id_desc', true, $excludeStories); } } else @@ -4028,7 +4024,7 @@ class storyModel extends model } else { - $stories = $this->getProductStories($productID, 0, 0, 'all', 'story', 'id_desc', true, $excludeStories, $pager); + $stories = $this->getProductStories($productID, $branch, 0, 'all', 'story', 'id_desc', true, $excludeStories, $pager); } } diff --git a/module/tree/model.php b/module/tree/model.php index cdfa10f47e..65f2921a90 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -372,10 +372,11 @@ class treeModel extends model { if($type == 'line') $rootID = 0; + $this->loadModel('branch'); $branches = array($branch => ''); if($branch) { - $branchName = $this->loadModel('branch')->getById($branch); + $branchName = $this->branch->getById($branch); $branches = array($branch => $branchName); $extra = array('rootID' => $rootID, 'branch' => $branch); } @@ -386,6 +387,22 @@ class treeModel extends model { if($product->type != 'normal') $branches = array(BRANCH_MAIN => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($rootID, 'noempty'); } + elseif($type == 'story' and $this->app->rawModule == 'projectstory') + { + $projectID = zget($extra, 'projectID', 0); + if($product->type != 'normal' and $projectID) + { + $projectBranches = $this->dao->select('branch')->from(TABLE_PROJECTPRODUCT) + ->where('project')->eq($projectID) + ->andWhere('product')->eq($product->id) + ->fetchPairs(); + + if(isset($projectBranches[BRANCH_MAIN])) $branches = array(BRANCH_MAIN => $this->lang->branch->main); + $branches += $this->dao->select('id, name')->from(TABLE_BRANCH) + ->where('id')->in($projectBranches) + ->fetchPairs(); + } + } /* Add for task #1945. check the module has case or no. */ if($type == 'case' and !empty($extra)) $this->loadModel('testtask'); diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 8953460de6..045570de02 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -732,6 +732,7 @@ class upgradeModel extends model case '15_7_1': $this->saveLogs('Execute 15_7_1'); $this->execSQL($this->getUpgradeFile('15.7.1')); + $this->updateObjectBranch(); $this->updateProjectStories(); $this->appendExec('15_7_1'); } @@ -5332,6 +5333,28 @@ class upgradeModel extends model return true; } + /** + * Update branch when object have module. + * + * @access public + * @return bool + */ + public function updateObjectBranch() + { + $moduleBranchPairs = $this->dao->select('id,branch')->from(TABLE_MODULE)->fetchPairs(); + + $storyModulePairs = $this->dao->select('module')->from(TABLE_STORY)->where('module')->ne(0)->fetchPairs(); + foreach($storyModulePairs as $moduleID) $this->dao->update(TABLE_STORY)->set('`branch`')->eq($moduleBranchPairs[$moduleID])->where('module')->eq($moduleID)->exec(); + + $bugModulePairs = $this->dao->select('module')->from(TABLE_BUG)->where('module')->ne(0)->fetchPairs(); + foreach($bugModulePairs as $moduleID) $this->dao->update(TABLE_BUG)->set('`branch`')->eq($moduleBranchPairs[$moduleID])->where('module')->eq($moduleID)->exec(); + + $caseModulePairs = $this->dao->select('module')->from(TABLE_CASE)->where('module')->ne(0)->fetchPairs(); + foreach($caseModulePairs as $moduleID) $this->dao->update(TABLE_CASE)->set('`branch`')->eq($moduleBranchPairs[$moduleID])->where('module')->eq($moduleID)->exec(); + + return true; + } + /** * Update branch of project linked stories. *