+ add whilte list feature.

+ add bugOwner field.
This commit is contained in:
wangchunsheng
2010-07-26 09:08:37 +00:00
parent 1fcf7d7156
commit 359f154255
6 changed files with 133 additions and 9 deletions

View File

@@ -61,6 +61,13 @@ class product extends control
$moduleID = ($browseType == 'bymodule') ? (int)$param : 0;
$queryID = ($browseType == 'bysearch') ? (int)$param : 0;
/* 检查是否有访问权限。*/
if(!$this->product->checkPriv($this->product->getById($productID)))
{
echo(js::alert($this->lang->product->accessDenied));
die(js::locate('back'));
}
/* 设置菜单。*/
$this->product->setMenu($this->products, $productID);
@@ -142,6 +149,8 @@ class product extends control
$this->view->header->title = $this->lang->product->create;
$this->view->position[] = $this->view->header->title;
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->users = $this->loadModel('user')->getPairs();
$this->display();
}
@@ -168,6 +177,8 @@ class product extends control
$this->view->position[] = html::a($this->createLink($this->moduleName, 'browse'), $product->name);
$this->view->position[] = $this->lang->product->edit;
$this->view->product = $product;
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->users = $this->loadModel('user')->getPairs();
$this->display();
}
@@ -187,6 +198,7 @@ class product extends control
$this->view->product = $product;
$this->view->actions = $this->loadModel('action')->getList('product', $productID);
$this->view->users = $this->user->getPairs();
$this->view->groups = $this->loadModel('group')->getPairs();
$this->display();
}

View File

@@ -42,14 +42,18 @@ $lang->product->ajaxGetPlans = "接口:计划列表";
$lang->product->errorFormat = '产品数据格式不正确';
$lang->product->errorEmptyName = '产品名称不能为空';
$lang->product->errorEmptyCode = '产品代号不能为空';
$lang->product->accessDenied = '您无权访问该产品';
$lang->product->id = '编号';
$lang->product->company = '所属公司';
$lang->product->name = '产品名称';
$lang->product->code = '产品代号';
$lang->product->order = '排序';
$lang->product->status = '状态';
$lang->product->desc = '产品描述';
$lang->product->id = '编号';
$lang->product->company = '所属公司';
$lang->product->name = '产品名称';
$lang->product->code = '产品代号';
$lang->product->order = '排序';
$lang->product->status = '状态';
$lang->product->desc = '产品描述';
$lang->product->bugOwner = 'Bug负责人';
$lang->product->acl = '访问控制';
$lang->product->whitelist = '分组白名单';
$lang->product->moduleStory = '按模块浏览';
$lang->product->searchStory = '搜索';
@@ -58,3 +62,7 @@ $lang->product->allStory = '全部需求';
$lang->product->statusList[''] = '';
$lang->product->statusList['normal'] = '正常';
$lang->product->statusList['closed'] = '结束';
$lang->product->aclList['open'] = '默认设置(有产品视图权限,即可访问)';
$lang->product->aclList['private'] = '私有项目(只有项目团队成员才能访问)';
$lang->product->aclList['custom'] = '自定义白名单(团队成员和白名单的成员可以访问)';

View File

@@ -47,6 +47,39 @@ class productModel extends model
}
}
/* 检查权限。*/
public function checkPriv($product)
{
/* 检查是否是管理员。*/
$account = ',' . $this->app->user->account . ',';
if(strpos($this->app->company->admins, $account) !== false) return true;
/* 访问级别为open不做任何处理。*/
if($product->acl == 'open') return true;
/* 获得团队的成员列表,供后面判断。*/
$teamMembers = $this->getTeamMemberPairs($product->id);
/* 级别为private。*/
if($product->acl == 'private')
{
return isset($teamMembers[$this->app->user->account]);
}
/* 级别为custom。*/
if($product->acl == 'custom')
{
if(isset($teamMembers[$this->app->user->account])) return true;
$userGroups = $this->loadModel('user')->getGroups($this->app->user->account);
$productGroups = explode(',', $product->whitelist);
foreach($userGroups as $groupID)
{
if(in_array($groupID, $productGroups)) return true;
}
return false;
}
}
/* 通过ID获取产品信息。*/
public function getById($productID)
{
@@ -63,11 +96,17 @@ class productModel extends model
public function getPairs()
{
$mode = $this->cookie->productMode;
return $this->dao->select('id,name')
$products = $this->dao->select('*')
->from(TABLE_PRODUCT)
->where('deleted')->eq(0)
->beginIF($mode == 'noclosed')->andWhere('status')->ne('closed')->fi()
->fetchPairs();
->fetchAll();
$pairs = array();
foreach($products as $product)
{
if($this->checkPriv($product)) $pairs[$product->id] = $product->name;
}
return $pairs;
}
/* 获取产品的的状态分组。*/
@@ -83,6 +122,8 @@ class productModel extends model
$product = fixer::input('post')
->stripTags('name,code')
->specialChars('desc')
->setIF($this->post->acl != 'custom', 'whitelist', '')
->join('whitelist', ',')
->get();
$this->dao->insert(TABLE_PRODUCT)
->data($product)
@@ -103,6 +144,8 @@ class productModel extends model
$product = fixer::input('post')
->stripTags('name,code')
->specialChars('desc')
->setIF($this->post->acl != 'custom', 'whitelist', '')
->join('whitelist', ',')
->get();
$this->dao->update(TABLE_PRODUCT)
->data($product)
@@ -149,4 +192,12 @@ class productModel extends model
arsort($roadmap);
return $roadmap;
}
/* 获取团队成员。*/
public function getTeamMemberPairs($productID)
{
$projects = $this->dao->select('project')->from(TABLE_PROJECTPRODUCT)->where('product')->eq($productID)->fetchPairs();
if(!$projects) return array();
return $this->dao->select('account')->from(TABLE_TEAM)->where('project')->in($projects)->fetchPairs();
}
}

View File

@@ -23,6 +23,12 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<script language='Javascript'>
function setWhite(acl)
{
acl == 'custom' ? $('#whitelistBox').removeClass('hidden') : $('#whitelistBox').addClass('hidden');
}
</script>
<div class='yui-d0'>
<form method='post' target='hiddenwin'>
<table class='table-1'>
@@ -35,6 +41,10 @@
<th class='rowhead'><?php echo $lang->product->code;?></th>
<td><?php echo html::input('code', '', "class='text-2'");?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->bugOwner;?></th>
<td><?php echo html::select('bugOwner', $users, $this->app->user->account, "class='select-2'");?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->status;?></th>
<td><?php echo html::select('status', $lang->product->statusList, '', "class='select-2'");?></td>
@@ -43,6 +53,14 @@
<th class='rowhead'><?php echo $lang->product->desc;?></th>
<td><?php echo html::textarea('desc', '', "rows='5' class='area-1'");?></textarea></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->acl;?></th>
<td><?php echo html::radio('acl', $lang->product->aclList, 'open', "onclick='setWhite(this.value);'");?></td>
</tr>
<tr id='whitelistBox' class='hidden'>
<th class='rowhead'><?php echo $lang->product->whitelist;?></th>
<td><?php echo html::checkbox('whitelist', $groups);?></td>
</tr>
<tr><td colspan='2' class='a-center'><?php echo html::submitButton();?></td></tr>
</table>
</form>

View File

@@ -23,6 +23,12 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<script language='Javascript'>
function setWhite(acl)
{
acl == 'custom' ? $('#whitelistBox').removeClass('hidden') : $('#whitelistBox').addClass('hidden');
}
</script>
<div class='yui-d0'>
<form method='post' target='hiddenwin'>
<table align='center' class='table-1'>
@@ -35,6 +41,10 @@
<th class='rowhead'><?php echo $lang->product->code;?></th>
<td><?php echo html::input('code', $product->code, "class='text-2'");?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->bugOwner;?></th>
<td><?php echo html::select('bugOwner', $users, $product->bugOwner, "class='select-2'");?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->status;?></th>
<td><?php echo html::select('status', $lang->product->statusList, $product->status, "class='select-2'");?></td>
@@ -43,6 +53,14 @@
<th class='rowhead'><?php echo $lang->product->desc;?></th>
<td><?php echo html::textarea('desc', $product->desc, "rows='5' class='area-1'");?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->acl;?></th>
<td><?php echo html::radio('acl', $lang->product->aclList, $product->acl, "onclick='setWhite(this.value);'");?></td>
</tr>
<tr id='whitelistBox' <?php if($product->acl != 'custom') echo "class='hidden'";?>>
<th class='rowhead'><?php echo $lang->product->whitelist;?></th>
<td><?php echo html::checkbox('whitelist', $groups, $product->whitelist);?></td>
</tr>
<tr><td colspan='2' class='a-center'><?php echo html::submitButton();?></td></tr>
</table>
</form>

View File

@@ -34,6 +34,10 @@
<th class='rowhead'><?php echo $lang->product->code;?></th>
<td><?php echo $product->code;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->bugOwner;?></th>
<td><?php echo $users[$product->bugOwner];?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->status;?></th>
<td><?php echo $lang->product->statusList[$product->status];?></td>
@@ -42,6 +46,19 @@
<th class='rowhead'><?php echo $lang->product->desc;?></th>
<td><?php echo nl2br($product->desc);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->acl;?></th>
<td><?php echo $lang->product->aclList[$product->acl];?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->product->whitelist;?></th>
<td>
<?php
$whitelist = explode(',', $product->whitelist);
foreach($whitelist as $groupID) if(isset($groups[$groupID])) echo $groups[$groupID] . '&nbsp;';
?>
</td>
</tr>
</table>
<div class='a-center f-16px strong'>
<?php