* change the tree module.

This commit is contained in:
wangchunsheng
2010-07-22 08:09:42 +00:00
parent 6d4ffce38f
commit 7cecf1682f
7 changed files with 40 additions and 41 deletions
+4 -4
View File
@@ -156,7 +156,7 @@ class bug extends control
$this->config->bug->search['actionURL'] = $this->createLink('bug', 'browse', "productID=$productID&browseType=bySearch&queryID=myQueryID");
$this->config->bug->search['queryID'] = $queryID;
$this->config->bug->search['params']['product']['values'] = array($productID => $this->products[$productID], 'all' => $this->lang->bug->allProduct);
$this->config->bug->search['params']['module']['values'] = $this->tree->getOptionMenu($productID, $viewType = 'bug', $rooteModuleID = 0);
$this->config->bug->search['params']['module']['values'] = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0);
$this->config->bug->search['params']['project']['values'] = $this->product->getProjectPairs($productID);
$this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getProductBuildPairs($productID);
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->build->getProductBuildPairs($productID);
@@ -172,7 +172,7 @@ class bug extends control
$this->view->position = $position;
$this->view->productID = $productID;
$this->view->productName = $this->products[$productID];
$this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'bug', $rooteModuleID = 0, array('treeModel', 'createBugLink'));
$this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'bug', $startModuleID = 0, array('treeModel', 'createBugLink'));
$this->view->browseType = $browseType;
$this->view->bugs = $bugs;
$this->view->users = $users;
@@ -292,7 +292,7 @@ class bug extends control
$this->view->productID = $productID;
$this->view->productName = $this->products[$productID];
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $rooteModuleID = 0);
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0);
$this->view->stories = $stories;
$this->view->users = $this->user->getPairs('noclosed,nodeleted');
$this->view->projects = $this->product->getProjectPairs($productID);
@@ -388,7 +388,7 @@ class bug extends control
$this->view->bug = $bug;
$this->view->productID = $productID;
$this->view->productName = $this->products[$productID];
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $rooteModuleID = 0);
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0);
$this->view->currentModuleID = $currentModuleID;
$this->view->projects = $this->product->getProjectPairs($bug->product);
$this->view->stories = $bug->project ? $this->story->getProjectStoryPairs($bug->project) : $this->story->getProductStoryPairs($bug->product);
+1 -1
View File
@@ -115,7 +115,7 @@ class product extends control
$this->view->productName = $this->products[$productID];
$this->view->moduleID = $moduleID;
$this->view->stories = $stories;
$this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'product', $rooteModuleID = 0, array('treeModel', 'createStoryLink'));
$this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'story', $startModuleID = 0, array('treeModel', 'createStoryLink'));
$this->view->parentModules = $this->tree->getParents($moduleID);
$this->view->pager = $pager;
$this->view->users = $this->user->getPairs('noletter');
+1 -1
View File
@@ -123,7 +123,7 @@ function search(active)
<div class='a-right'>
<?php if(common::hasPriv('product', 'edit')) echo html::a($this->createLink('product', 'edit', "productID=$productID"), $lang->edit);?>
<?php if(common::hasPriv('product', 'delete')) echo html::a($this->createLink('product', 'delete', "productID=$productID&confirm=no"), $lang->delete, 'hiddenwin');?>
<?php if(common::hasPriv('tree', 'browse')) echo html::a($this->createLink('tree', 'browse', "productID=$productID&view=product"), $lang->tree->manage);?>
<?php if(common::hasPriv('tree', 'browse')) echo html::a($this->createLink('tree', 'browse', "rootID=$productID&view=story"), $lang->tree->manage);?>
</div>
</div>
</div>
+2 -2
View File
@@ -49,7 +49,7 @@ class story extends control
$product = $this->product->getById($productID);
$products = $this->product->getPairs();
$users = $this->user->getPairs('nodeleted');
$moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'product');
$moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story');
/* 设置菜单。*/
$this->product->setMenu($products, $product->id);
@@ -75,7 +75,7 @@ class story extends control
$product = $this->product->getById($story->product);
$products = $this->product->getPairs();
$users = $this->user->getPairs('nodeleted');
$moduleOptionMenu = $this->tree->getOptionMenu($product->id, $viewType = 'product');
$moduleOptionMenu = $this->tree->getOptionMenu($product->id, $viewType = 'story');
/* 设置菜单。*/
$this->product->setMenu($products, $product->id);
+3 -3
View File
@@ -110,7 +110,7 @@ class testcase extends control
$this->view->position[] = $this->lang->testcase->common;
$this->view->productID = $productID;
$this->view->productName = $this->products[$productID];
$this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'case', $rooteModuleID = 0, array('treeModel', 'createCaseLink'));
$this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'case', $startModuleID = 0, array('treeModel', 'createCaseLink'));
$this->view->moduleID = $moduleID;
$this->view->pager = $pager;
$this->view->users = $this->user->getPairs('noletter');
@@ -151,7 +151,7 @@ class testcase extends control
$this->view->productID = $productID;
$this->view->users = $users;
$this->view->productName = $this->products[$productID];
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'case', $rooteModuleID = 0);
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0);
$this->view->currentModuleID = $currentModuleID;
$this->view->stories = $this->story->getProductStoryPairs($productID);
@@ -228,7 +228,7 @@ class testcase extends control
$this->view->position = $position;
$this->view->productID = $productID;
$this->view->productName = $this->products[$productID];
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'case', $rooteModuleID = 0);
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0);
$this->view->currentModuleID = $currentModuleID;
$this->view->users = $users;
$this->view->stories = $this->story->getProductStoryPairs($productID);
+2 -3
View File
@@ -46,7 +46,7 @@ class tree extends control
{
$product = $this->product->getById($productID);
if($viewType == 'product')
if($viewType == 'story')
{
/* 设置菜单。*/
$this->product->setMenu($this->product->getPairs(), $productID, 'product');
@@ -106,7 +106,7 @@ class tree extends control
die(js::reload('parent'));
}
$this->view->module = $this->tree->getById($moduleID);
$this->view->optionMenu = $this->tree->getOptionMenu($this->view->module->product, $this->view->module->view);
$this->view->optionMenu = $this->tree->getOptionMenu($this->view->module->root, $this->view->module->type);
/* 去掉自己和child。*/
$childs = $this->tree->getAllChildId($moduleID);
@@ -133,7 +133,6 @@ class tree extends control
$this->tree->manageChild($productID, $viewType, $_POST['parentModuleID'], $_POST['modules']);
die(js::reload('parent'));
}
}
/* 删除某一个模块。*/
+27 -27
View File
@@ -32,29 +32,29 @@ class treeModel extends model
}
/* 生成查询的sql语句。*/
private function buildMenuQuery($productID, $viewType, $rootModuleID)
private function buildMenuQuery($rootID, $type, $startModule)
{
/* 查找rootModule。*/
$rootModulePath = '';
if($rootModuleID > 0)
/* 查找startModule。*/
$startModulePath = '';
if($startModule > 0)
{
$rootModule = $this->getById($rootModuleID);
if($rootModule) $rootModulePath = $rootModule->path . '%';
$startModule = $this->getById($startModule);
if($startModule) $startModulePath = $startModule->path . '%';
}
return $this->dao->select('*')->from(TABLE_MODULE)
->where('product')->eq((int)$productID)
->andWhere('view')->eq($viewType)
->beginIF($rootModulePath)->andWhere('path')->like($rootModulePath)->fi()
->where('root')->eq((int)$rootID)
->andWhere('type')->eq($type)
->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi()
->orderBy('grade desc, `order`')
->get();
}
/* 获取模块的下类列表,用于生成select控件。*/
public function getOptionMenu($productID, $viewType = 'product', $rootModuleID = 0)
public function getOptionMenu($rootID, $type = 'story', $startModule = 0)
{
$treeMenu = array();
$stmt = $this->dbh->query($this->buildMenuQuery($productID, $viewType, $rootModuleID));
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule));
$modules = array();
while($module = $stmt->fetch()) $modules[$module->id] = $module;
@@ -108,10 +108,10 @@ class treeModel extends model
}
/* 获取树状的模块列表。*/
public function getTreeMenu($productID, $viewType = 'product', $rootModuleID = 0, $userFunc)
public function getTreeMenu($rootID, $type = 'root', $startModule = 0, $userFunc)
{
$treeMenu = array();
$stmt = $this->dbh->query($this->buildMenuQuery($productID, $viewType, $rootModuleID));
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule));
while($module = $stmt->fetch())
{
$linkHtml = call_user_func($userFunc, $module);
@@ -143,7 +143,7 @@ class treeModel extends model
/* 生成需求链接。*/
private function createStoryLink($module)
{
$linkHtml = html::a(helper::createLink('product', 'browse', "product={$module->product}&type=byModule&param={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
$linkHtml = html::a(helper::createLink('product', 'browse', "root={$module->root}&type=byModule&param={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
return $linkHtml;
}
@@ -152,8 +152,8 @@ class treeModel extends model
{
$linkHtml = $module->name;
if(common::hasPriv('tree', 'edit')) $linkHtml .= ' ' . html::a(helper::createLink('tree', 'edit', "module={$module->id}"), $this->lang->tree->edit, '', 'class="iframe"');
if(common::hasPriv('tree', 'browse')) $linkHtml .= ' ' . html::a(helper::createLink('tree', 'browse', "product={$module->product}&viewType={$module->view}&module={$module->id}"), $this->lang->tree->child);
if(common::hasPriv('tree', 'delete')) $linkHtml .= ' ' . html::a(helper::createLink('tree', 'delete', "product={$module->product}&module={$module->id}"), $this->lang->delete, 'hiddenwin');
if(common::hasPriv('tree', 'browse')) $linkHtml .= ' ' . html::a(helper::createLink('tree', 'browse', "root={$module->root}&type={$module->type}&module={$module->id}"), $this->lang->tree->child);
if(common::hasPriv('tree', 'delete')) $linkHtml .= ' ' . html::a(helper::createLink('tree', 'delete', "root={$module->root}&module={$module->id}"), $this->lang->delete, 'hiddenwin');
if(common::hasPriv('tree', 'updateorder')) $linkHtml .= ' ' . html::input("orders[$module->id]", $module->order, 'style="width:30px;text-align:center"');
return $linkHtml;
}
@@ -161,24 +161,24 @@ class treeModel extends model
/* 生成Bug链接。*/
private function createBugLink($module)
{
$linkHtml = html::a(helper::createLink('bug', 'browse', "product={$module->product}&type=byModule&param={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
$linkHtml = html::a(helper::createLink('bug', 'browse', "root={$module->root}&type=byModule&param={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
return $linkHtml;
}
/* 生成case链接。*/
private function createCaseLink($module)
{
$linkHtml = html::a(helper::createLink('testcase', 'browse', "product={$module->product}&type=byModule&param={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
$linkHtml = html::a(helper::createLink('testcase', 'browse', "root={$module->root}&type=byModule&param={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
return $linkHtml;
}
/* 获得某一个模块的直接下级模块。*/
public function getSons($productID, $moduleID, $viewType = 'product')
public function getSons($rootID, $moduleID, $type = 'root')
{
return $this->dao->select('*')->from(TABLE_MODULE)
->where('product')->eq((int)$productID)
->where('root')->eq((int)$rootID)
->andWhere('parent')->eq((int)$moduleID)
->andWhere('view')->eq($viewType)
->andWhere('type')->eq($type)
->orderBy('`order`')
->fetchAll();
}
@@ -211,7 +211,7 @@ class treeModel extends model
}
/* 更新某一个模块的子模块。*/
public function manageChild($productID, $viewType, $parentModuleID, $childs)
public function manageChild($rootID, $type, $parentModuleID, $childs)
{
$parentModule = $this->getByID($parentModuleID);
if($parentModule)
@@ -232,11 +232,11 @@ class treeModel extends model
/* 新增模块。*/
if(is_numeric($moduleID))
{
$module->product = $productID;
$module->root = $rootID;
$module->name = $moduleName;
$module->parent = $parentModuleID;
$module->grade = $grade;
$module->view = $viewType;
$module->type = $type;
$module->order = $this->post->maxOrder + $i * 10;
$this->dao->insert(TABLE_MODULE)->data($module)->exec();
$moduleID = $this->dao->lastInsertID();
@@ -275,9 +275,9 @@ class treeModel extends model
$this->dao->delete()->from(TABLE_MODULE)->where('id')->eq($moduleID)->exec(); // 删除自己。
$this->fixModulePath();
if($module->view == 'product') $this->dao->update(TABLE_STORY)->set('module')->eq($module->parent)->where('module')->eq($moduleID)->exec();
if($module->view == 'bug') $this->dao->update(TABLE_BUG)->set('module')->eq($module->parent)->where('module')->eq($moduleID)->exec();
if($module->view == 'case') $this->dao->update(TABLE_CASE)->set('module')->eq($module->parent)->where('module')->eq($moduleID)->exec();
if($module->type == 'story') $this->dao->update(TABLE_STORY)->set('module')->eq($module->parent)->where('module')->eq($moduleID)->exec();
if($module->type == 'bug') $this->dao->update(TABLE_BUG)->set('module')->eq($module->parent)->where('module')->eq($moduleID)->exec();
if($module->type == 'case') $this->dao->update(TABLE_CASE)->set('module')->eq($module->parent)->where('module')->eq($moduleID)->exec();
}
/* 修正modulePath字段。*/